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);