ā† Back to Upcase

Rails JSON API Serializing

Hey Guys,

What are you using today to serialize JSON APIs? I used ActiveModel::Serializer in the past but not sure if this is the right way today.

Looking for suggestions.

Thanks!

jsonapi-resources - https://github.com/cerebris/jsonapi-resources

1 Like

Iā€™m using active_model_serializers 0.10.x and they work pretty well for me (be aware there are quite a few significant differences between 0.8, 0.9 and 0.10).

Hey @orlando,

I was asking myself the same question lately because there seem to be quite a few options these days.

I think it depends on your use case and also your coding style. Some gems handle serialization in the view layer (e.g. Jbuilder, Rabl, etc.) and others in the model layer (ActiveModel::Serializers, JSONAPI::Resources, Roar.).

JSONAPI::Resources is great if you plan to stick with the JSON:API spec, but can also feel a bit heavy-handed (you have to incorporate its helper methods into your routes, controllers, and models).

I summarized the different options in a recent blog post that you might find helpful.

Check it out here: Which JSON Serializer To Use For A New Rails API?

1 Like