Build JSON and XML using RABL gem
RABL (Ruby API Builder Language) is a Rails templating system for generating JSON and XML. Generating JSON using ActiveRecord’s ‘to_json’ method is not much expressive and friendly. This is especially true when JSON representation is complex or does not match the exact schema defined within the database.
By using RABL, we can easily manage the format and the name of the attributes according to our need. For example, renaming an attribute or creating arbitrary nodes are extremely easy.
In my last brown bag session at Nascenia, I showed how to use RABL gem in a ROR application and generate JSON data that meets our requirement. Also, I demonstrated how to use inheritance and complex JSON data like deep nested format using RABL gem.
I am sharing my presentation here.
Feel free to comment below if you have any query on this.
Contributor: Junaid Alam, Software Engineer, Nascenia