jsonapi-rb / jsonapi-parser

Validate JSON API documents.
http://jsonapi-rb.org
MIT License
27 stars 10 forks source link

Parser returns nil? #6

Closed Rio517 closed 7 years ago

Rio517 commented 7 years ago

Perhaps I'm using this incorrectly. I would imagine JSONAPI.parse_response!(payload) returns a parsed response. If I open up IRB, this is what I see.

require 'jsonapi/parser'

#taken from specs
payload = {'data' => [{'type' => 'articles', 'id' => '1', 'attributes' => { 'title' => 'JSON API paints my bikeshed!' }, 'links' => { 'self' => 'http://example.com/articles/1' }, 'relationships' => {'author' => {'links' => {'self' => 'http://example.com/articles/1/relationships/author', 'related' => 'http://example.com/articles/1/author'}, 'data' => { 'type' => 'people', 'id' => '9' } }, 'journal' => {'data' => nil }, 'comments' => {'links' => {'self' => 'http://example.com/articles/1/relationships/comments', 'related' => 'http://example.com/articles/1/comments'}, 'data' => [{ 'type' => 'comments', 'id' => '5' }, { 'type' => 'comments', 'id' => '12' } ] } } } ], 'meta' => { 'count' => '13' } }

irb(main):005:0> JSONAPI.parse_response!(payload)
=> nil
beauby commented 7 years ago

Hi @Rio517 – at the moment the parser simply ensures syntactic validity, but provides no API to query the document.

Rio517 commented 7 years ago

Got it. Thanks!