her icon indicating copy to clipboard operation
her copied to clipboard

Can't parse root with parse_root_in_json

Open cakejelly opened this issue 9 years ago • 3 comments

I'm trying to consume an API that returns data in the format below but I can't seem to get parse_root_in_json to parse it properly. Any ideas why this isn't returning anything?

// GET /users

{
  "data": [{"id": 1234, first_name: "user1"}, {"id": 1234, first_name: "user1"}, ...]
}

My model:

class User
   include Her::Model
   parse_root_in_json :data
end

I've also tried parse_root_in_json true, format: :active_model_serializers and root_element :data but nothing seems to work

cakejelly avatar Apr 13 '15 23:04 cakejelly

your api is a json-api, which isn't AMS json, so that format string is wrong. @hubert is this supported now?

bf4 avatar Apr 25 '15 06:04 bf4

@cakejelly i'm just returning from holiday now, so can take a closer look.

i may have a fix for this here: https://github.com/remiprev/her/pull/326

could you post a stack trace of the error you are getting?

hubert avatar May 04 '15 17:05 hubert

This initially appears to be the same sort of issue as mine in #380. Though it might be related to the formatting of the response. A stack trace would clarify the problem.

fractaledmind avatar Oct 22 '15 12:10 fractaledmind