{"action":"created","issue":{"url":"https://api.github.com/repos/apotonick/roar/issues/180","labels_url":"https://api.github.com/repos/apotonick/roar/issues/180/labels{/name}","comments_url":"https://api.github.com/repos/apotonick/roar/issues/180/comments","events_url":"https://api.github.com/repos/apotonick/roar/issues/180/events","html_url":"https://github.com/apotonick/roar/issues/180","id":123758473,"number":180,"title":"Error trying to parse jsonapi data","user":{"login":"mustela","id":325222,"avatar_url":"https://avatars.githubusercontent.com/u/325222?v=3","gravatar_id":"","url":"https://api.github.com/users/mustela","html_url":"https://github.com/mustela","followers_url":"https://api.github.com/users/mustela/followers","following_url":"https://api.github.com/users/mustela/following{/other_user}","gists_url":"https://api.github.com/users/mustela/gists{/gist_id}","starred_url":"https://api.github.com/users/mustela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mustela/subscriptions","organizations_url":"https://api.github.com/users/mustela/orgs","repos_url":"https://api.github.com/users/mustela/repos","events_url":"https://api.github.com/users/mustela/events{/privacy}","received_events_url":"https://api.github.com/users/mustela/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-24T04:58:48Z","updated_at":"2015-12-24T13:10:11Z","closed_at":null,"body":"Hi there!\r\n\r\nI'm trying to parse the following json \r\n```json\r\n{\r\n   \"data\": {\r\n      \"type\": \"organizations\",\r\n      \"attributes\": {\r\n         \"name\": \"New org\"\r\n      }\r\n   }\r\n}\r\n```\r\n\r\nSo I have an Organization Decorator\r\n\r\n```ruby\r\nrequire \"roar/json/json_api\"\r\nrequire \"json\"\r\n\r\nclass OrganizationDecorator < Roar::Decorator\r\n  include Roar::JSON::JSONAPI\r\n  type :organizations\r\n\r\n  # attributes: {}\r\n  property :id\r\n  property :name\r\n\r\nend\r\n```\r\n\r\n`Organization` is a rails model, and then I'm trying to parse it\r\n\r\n```ruby\r\nOrganizationDecorator.prepare(Organization.new).from_json('{\"data\":{\"type\":\"organizations\", \"attributes\":{\"name\":\"New org\"}}}')\r\n````\r\n\r\nBut I can't make it works, I keep getting: `undefined method `[]' for nil:NilClass`\r\n\r\n```\r\n[\"/usr/local/lib/ruby/gems/2.1.0/gems/roar-1.0.4/lib/roar/json/json_api.rb:50:in `from_hash'\",\r\n \"/usr/local/lib/ruby/gems/2.1.0/gems/roar-1.0.4/lib/roar/json/json_api.rb:131:in `from_hash'\",\r\n \"/usr/local/lib/ruby/gems/2.1.0/gems/representable-2.3.0/lib/representable/json.rb:35:in `from_json'\",\r\n````\r\n\r\nWhat I'm doing wrong? \r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/apotonick/roar/issues/comments/167107621","html_url":"https://github.com/apotonick/roar/issues/180#issuecomment-167107621","issue_url":"https://api.github.com/repos/apotonick/roar/issues/180","id":167107621,"user":{"login":"mustela","id":325222,"avatar_url":"https://avatars.githubusercontent.com/u/325222?v=3","gravatar_id":"","url":"https://api.github.com/users/mustela","html_url":"https://github.com/mustela","followers_url":"https://api.github.com/users/mustela/followers","following_url":"https://api.github.com/users/mustela/following{/other_user}","gists_url":"https://api.github.com/users/mustela/gists{/gist_id}","starred_url":"https://api.github.com/users/mustela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mustela/subscriptions","organizations_url":"https://api.github.com/users/mustela/orgs","repos_url":"https://api.github.com/users/mustela/repos","events_url":"https://api.github.com/users/mustela/events{/privacy}","received_events_url":"https://api.github.com/users/mustela/received_events","type":"User","site_admin":false},"created_at":"2015-12-24T13:10:11Z","updated_at":"2015-12-24T13:10:11Z","body":"Great! Its partially working now because relathionships are not being loaded. \r\n\r\nThis is the json\r\n```json\r\n{\r\n  \"data\": {\r\n    \"type\": \"organization\",\r\n    \"attributes\": {\r\n      \"name\": \"New org\",\r\n      \"description\": \"My org description\"\r\n    },\r\n    \"relationships\": {\r\n      \"organization_type\": {\r\n        \"data\": { \"type\": \"organization_type\", \"id\": \"5f7118bd-afd9-4943-a101-2d5d1b7e1143\" }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nAnd the decorator\r\n\r\n```ruby\r\nrequire \"roar/json/json_api\"\r\nrequire \"json\"\r\n\r\nclass OrganizationDecorator < Roar::Decorator\r\n  include Roar::JSON::JSONAPI\r\n  type :organizations\r\n\r\n  # attributes: {}\r\n  property :id\r\n  property :name\r\n\r\n  # relationships\r\n  has_one :organization_type, populator: ::Representable::FindOrInstantiate do\r\n    type :organization_types\r\n\r\n    property :id\r\n    property :name\r\n  end\r\nend\r\n``` \r\n\r\nAnd the result\r\n\r\n```\r\n#<Organization:0x007fc8993c6c20\r\n id: nil,\r\n name: \"\",\r\n logo_url: nil,\r\n website_url: nil,\r\n billing_user_id: nil,\r\n organization_type_id: nil,\r\n tags: nil,\r\n description: nil,\r\n social: {},\r\n founded: nil,\r\n slug: nil,\r\n created_at: nil,\r\n updated_at: nil,\r\n deleted_at: nil>\r\n```\r\n\r\nAs you can see the organization type hasn't ben loaded `organization_type_id: nil,`"}}