Skip to content
Colin Harrington edited this page Sep 20, 2016 · 9 revisions

JSON API Notes

See http://jsonapi.org.

The Very Basics

JSONAPI Basics

Rendering JSONAPI

Rendering JSONAPI formatted items

Handling JSONAPI

Handling JSONAPI formatted data

Errors

Error handling implemented via http://jsonapi.org/format/#errors

{
    "errors":[
        {
            "code":"blank",
            "detail":"Property [title] of class [class grails.example.Article] cannot be blank",
            "source":{
                "object":"grails.example.Article",
                "field":"title",
                "rejectedValue":"",
                "bindingError":false
            }
        },
        {
            "code":"nullable",
            "detail":"Property [author] of class [class grails.example.Article] cannot be null",
            "source":{
                "object":"grails.example.Article",
                "field":"author",
                "rejectedValue":null,
                "bindingError":false
            }
        }
    ]
}

#Links Support for top-level links including related associations

{  
    "data":{  
        "type":"article",
        "id":"1",
        "attributes":{  
            "title":"Save the Gumbo",
            "version":0
        },
        "relationships":{  
            "author":{  
                "data":{  
                    "type":"person",
                    "id":"1"
                }
            }
        }
    },
    "links":{  
        "self":"/articles?id=1",
        "related":{  
            "href":"/people?id=1"
        }
    }
}
Clone this wiki locally