drf_braces.parsers module¶
-
class
drf_braces.parsers.
SortedJSONParser
[source]¶ Bases:
rest_framework.parsers.JSONParser
Parses JSON-serialized data into OrderedDict.
-
class
drf_braces.parsers.
StrippingJSONParser
[source]¶ Bases:
rest_framework.parsers.JSONParser
Strip the outer layer of JSON, returning only inner layer.
This is a convenience class, so that API creators do not need to wrap their serializers in a “parent serializer” for the sole purpose of stripping out the top-level node.
Place desired root into parser-context as ‘parse-root’. Only supports descending one level of nesting.
Caller is expected to add ‘parse_root’ to the parser’s context; a convenient place to do this is in a GenericApiView subclass’s get_parser_context() method.
Example, for parse_root of “dt_application”:
input json: { "dt_application": { "node1": 1234 } } output dictionary: { "node1": 1234 }