Skip to content

Missing API to serialize a JSONObject to a byte writer with serialization settings #1

@popcron

Description

@popcron

currently, this can be done:

using ByteWriter byteWriter = new();
JSONObject jsonObject = GetJSONObject();
byteWriter.WriteObject(jsonObject);

but it appends the json bytes in the most compact form which is great, but theres no way to pass serialization settings. have to do this as a workaround:

using ByteWriter byteWriter = new();
using Text jsonText = new();
JSONObject jsonObject = GetJSONObject();
jsonObject.ToString(jsonText, SerializationSettings.JSON5PrettyPrinted);
byteWriter.WriteUTF8(jsonText.AsSpan());

preferably there should be api for writing bytes with serialization settings as a parameter:

using ByteWriter byteWriter = new();
JSONObject jsonObject = GetJSONObject();
jsonObject.WriteObject(byteWriter, SerializationSettings.JSON5PrettyPrinted);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions