@@ -70,14 +70,11 @@ def parse_metadata(result):
7070 else :
7171 return {}
7272
73- def parse (self , stream , media_type = None , parser_context = None ):
73+ def parse_data (self , result , parser_context ):
7474 """
75- Parses the incoming bytestream as JSON and returns the resulting data
75+ Formats the output of calling JSONParser to match the JSON:API specification
76+ and returns the result.
7677 """
77- result = super ().parse (
78- stream , media_type = media_type , parser_context = parser_context
79- )
80-
8178 if not isinstance (result , dict ) or "data" not in result :
8279 raise ParseError ("Received document does not contain primary data" )
8380
@@ -166,3 +163,13 @@ def parse(self, stream, media_type=None, parser_context=None):
166163 parsed_data .update (self .parse_relationships (data ))
167164 parsed_data .update (self .parse_metadata (result ))
168165 return parsed_data
166+
167+ def parse (self , stream , media_type = None , parser_context = None ):
168+ """
169+ Parses the incoming bytestream as JSON and returns the resulting data
170+ """
171+ result = super ().parse (
172+ stream , media_type = media_type , parser_context = parser_context
173+ )
174+
175+ return self .parse_data (result , parser_context )
0 commit comments