Ask A Question

Notifications

You’re not receiving notifications from this thread.

JSON:API Format and Active Model Serializers Discussion

Raphael Ramos Raphael Ramos

Very nice video as always, but there's an editing problem on your video. Check it between 15:00 and 17:00. You actually repeat the same thing twice, but the wordings you use is different, I guess you forgot to remove one of those when editing the video.

But anyway, great video!

Reply

Haha crap, bad edit!

Reply

Chris, what if my current API code base doesn't really in RESTful shape? Does AMS still can help?

Example of my current routes:

1. /transaction_history.json (I don't have TransactionHistory model)
2. /buy.json (I don't have Buy model)
3. /user_status.json (mixed data between User model and several other models)

I'm not using AMS now. Still using render :json => {} approach inside my API controller.

Thanks.

Reply

AMS doesn't care about your URLs, it just takes models and turns them into JSON. You can use any routes you want. Ideally for JSON:API spec, you'll want some restful routes for the objects, but it's also fine to have routes like you mentioned for ease of use. I think of routes for concepts often, it doesn't have to be specifically for a model. For example, your routes make sense because they offer up clear endpoints for different concepts for each one.

Reply

I would love it if you would do as many tutorials on api's as possible, and I would like it if you did a tutorial on the doorkeeper gem as well.

By the way great episode!

Reply

Hi Chris. Thanks for video.
Can you tell me - why json api is better than basic json output?
Json APi has more unneeded information(big response size). It's terrible to work with Json API from JS clients, because you will need to write a normalizer for get access to data through dot(location.recordings...).

Reply

This is a really interesting question. I was thing about the same thing when I saw this much of information.

Reply

Paging using this techniques would be awesome.

Reply

Hey Chris! What would you recommend for pagination? Using some gems or doing it from scratch? Could you also point out some great resources on the topic? Thx

Reply

I would recommend either will_paginate or Kaminari. Both work really well and only have minor API differences between the two. They both have over 13M downloads too, so they're similarly popular and I wouldn't really say one is better than the other. If you use something like Administrate or something that already depends upon one, then I'd say to just use that for your app as well.

I'll be making a video how to add the pages into the JSON api spec so you can see how that's done.

Reply

Hey, did you ended up doing a second video with the links and pagination? :)

Reply

Hey Chris. Thanks for the awesome video.

I'd like to know about your courses sooner!

Would be wonderful if you add the links information in a video as mentioned in this video.

In addition, I had asked at work why they did not use this JSON Api format and they said to me that HAL and HATEOAS are better.

Do you know which are the advantages of those three ways of JSON Format?

Thanks so much for your attention.

Hugs.

Kelvin Matheus

Reply
zerocool81 zerocool81

Hi Chris, have you recorded another screencast for rendering out the links for objects as JSON:API recommends? I don't seem to have much luck finding any other tutorials on the subject. You're the closest I've found... I'd really like to figure out how to do that. Thanks!

Reply
Ping. I'd like to see more AMS topics as well. 
Hopefully you're not over the topic :-D
Reply
On second thought, i just did some digging and it seems that AMS might be on the down turn. The repo suggests looking at https://github.com/Netflix/fast_jsonapi and http://jsonapi-rb.org/ I'm going to head over there for a spell.
Reply
Thank a lot for helpful tutorial Chris Oliver. I just start using MacVim couple day ago and I really excited about it. I would like to know that how do you navigate the file? something like you do at 7:20. Thank so much :D 
Reply

Hi Chris, which Chrome extension are you using for viewing JSON responses?

Reply

Ukaza, I think it is this extension.

https://github.com/callumlocke/json-formatter

Reply

After some digging I found and chose this gem: https://github.com/jsonapi-serializer/jsonapi-serializer

Seems its fastest and still maintained.
Not sure how it will be in long run.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.