You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Writer flushes its output stream when it ends the top-level object or array (i.e. in EndObject() or EndArray() when the stack is empty.) However, as of the new JSON spec, there is no longer a requirement that a "JSON text" start with an object or array. A standalone value such as 5 or "HI" is a valid JSON text:
o Changed the definition of "JSON text" so that it can be any JSON
value, removing the constraint that it be an object or array.
When a Writer is used with a FileWriteStream to write a standalone value, it does not flush, so the value is discarded instead of being written to the file.
This can be partly fixed by adding a destructor to FileWriteStream so that it always flushes when destroyed:
However this would only fix FileWriteStream. If a Writer is connected to a socket for example, it won't flush in between writing standalone values. If you want to preserve the "automatic flushing" in between objects written to a stream, you may need to add a flush check to all value write functions, but this could adversely affect performance.
Alternatively, if you're comfortable breaking a bit of backwards compatibility for people using RapidJSON for RPC, you could remove all automatic flushing from the writer and use only destructors on the underlying streams to flush. It would then be up to users to flush manually in between writing objects if they want them flushed to a socket for example.
The text was updated successfully, but these errors were encountered:
Writer
flushes its output stream when it ends the top-level object or array (i.e. inEndObject()
orEndArray()
when the stack is empty.) However, as of the new JSON spec, there is no longer a requirement that a "JSON text" start with an object or array. A standalone value such as5
or"HI"
is a valid JSON text:https://tools.ietf.org/html/rfc7158
When a
Writer
is used with aFileWriteStream
to write a standalone value, it does not flush, so the value is discarded instead of being written to the file.This can be partly fixed by adding a destructor to FileWriteStream so that it always flushes when destroyed:
However this would only fix
FileWriteStream
. If aWriter
is connected to a socket for example, it won't flush in between writing standalone values. If you want to preserve the "automatic flushing" in between objects written to a stream, you may need to add a flush check to all value write functions, but this could adversely affect performance.Alternatively, if you're comfortable breaking a bit of backwards compatibility for people using RapidJSON for RPC, you could remove all automatic flushing from the writer and use only destructors on the underlying streams to flush. It would then be up to users to flush manually in between writing objects if they want them flushed to a socket for example.
The text was updated successfully, but these errors were encountered: