@@ -70,14 +70,11 @@ def parse_metadata(result):
70
70
else :
71
71
return {}
72
72
73
- def parse (self , stream , media_type = None , parser_context = None ):
73
+ def parse_data (self , result , parser_context ):
74
74
"""
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.
76
77
"""
77
- result = super ().parse (
78
- stream , media_type = media_type , parser_context = parser_context
79
- )
80
-
81
78
if not isinstance (result , dict ) or "data" not in result :
82
79
raise ParseError ("Received document does not contain primary data" )
83
80
@@ -166,3 +163,13 @@ def parse(self, stream, media_type=None, parser_context=None):
166
163
parsed_data .update (self .parse_relationships (data ))
167
164
parsed_data .update (self .parse_metadata (result ))
168
165
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