|
CX Framework
Cross-platform C utility framework
|
Functions | |
| JSONOut * | jsonOutBegin (StreamBuffer *sb, flags_t flags) |
| bool | jsonOut (JSONOut *jo, JSONParseEvent *ev) |
| void | jsonOutEnd (JSONOut **jo) |
Event-driven JSON output using parse events.
| bool jsonOut | ( | JSONOut * | jo, |
| JSONParseEvent * | ev | ||
| ) |
bool jsonOut(JSONOut *jo, JSONParseEvent *ev)
Writes a JSON element using a parse event.
Call this repeatedly with appropriate JSONParseEvent structures to build the JSON output. Events should be sent in a valid sequence (e.g., object keys must be followed by values).
| jo | JSON output context from jsonOutBegin() |
| ev | Parse event describing the element to output |
| JSONOut * jsonOutBegin | ( | StreamBuffer * | sb, |
| flags_t | flags | ||
| ) |
JSONOut *jsonOutBegin(StreamBuffer *sb, flags_t flags)
Begins event-driven JSON output to a stream buffer.
Initializes a JSON output context that writes to the stream buffer in PUSH mode. After calling this, repeatedly call jsonOut() with JSONParseEvent structures to build the output, then call jsonOutEnd() to finalize.
| sb | Stream buffer to write to |
| flags | Output formatting flags from JSON_OUT_FLAGS |
Example:
| void jsonOutEnd | ( | JSONOut ** | jo | ) |
Finalizes JSON output and cleans up the context.
Flushes any remaining data to the stream buffer, finishes the producer, and frees the JSON output context.
| jo | Pointer to JSON output context (set to NULL after call) |