her
her copied to clipboard
Can't parse root with parse_root_in_json
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
your api is a json-api, which isn't AMS json, so that format string is wrong. @hubert is this supported now?
@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?
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.