Rabl, Jbuilder or manual json assembly for api?

To create api for a large-scale application, which method combines performance better, should I use Rabl, Jbuilder or create json objects manually? I am creating api / endpoints for mobile applications.

+8
json api ruby-on-rails rabl jbuilder
source share
2 answers

In terms of performance, you should try to create basic performance tests and profile them.

Suppose the hardest part of your application model associations is your weakest point in terms of responsiveness and the development of your test.

Generally speaking, there are several other things that you should consider.

  • as_json overrides will quickly get out of hand in your models and become a fragile part of your application. Many people view the API as a point of view, and therefore the logic for it should be separated from the Model in order to remain flexible / interchangeable and verifiable. This is the main advantage of both JBuilder and RABL. Ultimately, even a simple JSON api built with as_json will ask for refactoring when it needs to be extended, so the initial complexity of learning / using DSL is probably worth it. However, there are, of course, some cases where it is normal to use as_json , you just need to know about scalability and maintenance issues.

  • Jbuilder had rather poor performance, however it was significantly improved around the same time that this question was first published. RABL used to be more productive. At the moment, Jbuilder is advancing faster.

  • RABL DSL is generally less favorable than Jbuilder, it can be difficult to start and maintain. Jbuilder DSL is generally simpler and easier to learn / use, in both cases YMMV, but the general consensus seems to be that Jbuilder is easier to pick up and run from.

Since this issue is 5 months, it’s a pity that I have not seen this before, I expect that the decision has already been made a long time ago.

+17
source share

I suggest Jbuilder. Since Jbuilder has the core development of Rails. Therefore, there may not be a problem during the upgrade.

0
source share

All Articles