Skip to content

utils.json

Warning

These are internal functions that you probably don't want to interact with directly.

Functions for serializing to JSON.

collapse_names

collapse_names(json_object)

Collapse all name dictionaries in a serialized JSON object to a single line.

Parameters:

Name Type Description Default
json_object bytes

A byte string representing a JSON object, e.g. as produced by msgspec.json.format.

required

Returns:

Type Description
bytes

A byte string of the same object, but with name dictionaries collapsed to a single line.

Note

This assumes that name dictionaries only ever contain strings as values.