rest_framework_json_api.parsers module

Parsers

classrest_framework_json_api.parsers.JSONParser

Bases: JSONParser

Similar to JSONRenderer, the JSONParser you may override the following methods if you need highly custom parsing control.

A JSON:API client will send a payload that looks like this:

{
"data":{
"type":"identities",
"id":1,
"attributes":{
"first_name":"John",
"last_name":"Coltrane"
}
}
}

We extract the attributes so that DRF serializers can work as normal.

media_type='application/vnd.api+json'
renderer_class

alias of JSONRenderer

staticparse_attributes(data)
staticparse_relationships(data)
staticparse_metadata(result)

Returns a dictionary which will be merged into parsed data of the request. By default, it reads the meta content in the request body and returns it in a dictionary with a _meta top level key.

parse_data(result, parser_context)

Formats the output of calling JSONParser to match the JSON:API specification and returns the result.

parse(stream, media_type=None, parser_context=None)

Parses the incoming bytestream as JSON and returns the resulting data