CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
jsonout.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cx/ssdtree/ssdshared.h>
7#include "jsoncommon.h"
8
9typedef struct JSONOut JSONOut;
10
28
34
40#define JSON_Indent(x) (x & JSON_Indent_Mask)
41
42CX_C_BEGIN
43
47 JSON_Indent_Mask = 0x0000001f,
49 JSON_Compact = 0x00000100,
51 JSON_Single_Line = 0x00000200,
53 JSON_ASCII_Only = 0x00000400,
54
56 JSON_Unix_EOL = 0x00010000,
58 JSON_Windows_EOL = 0x00020000,
59
61 JSON_Pretty = 0x00000004,
63 JSON_Minimal = 0x00000300,
64};
65
67
73
115_Ret_valid_ JSONOut* jsonOutBegin(_Inout_ StreamBuffer* sb, flags_t flags);
116
128_Check_return_ bool jsonOut(_Inout_ JSONOut* jo, _In_ const JSONParseEvent* ev);
129
138_At_(*jo, _Pre_valid_ _Post_invalid_) void jsonOutEnd(_Inout_ JSONOut** jo);
139
162void jsonStrEscape(_Inout_ string* out, _In_opt_ strref val, flags_t flags);
163
165
171
198#define jsonOutTree(sb, tree, ...) \
199 _jsonOutTree(sb, tree, opt_flags(__VA_ARGS__), (SSDLockState*)_ssdCurrentLockState)
200bool _jsonOutTree(_Inout_ StreamBuffer* sb, _In_ SSDNode* tree, flags_t flags,
201 _Inout_opt_ SSDLockState* _ssdCurrentLockState);
202
229#define jsonTreeToString(out, tree, ...) \
230 _jsonTreeToString(out, tree, opt_flags(__VA_ARGS__), (SSDLockState*)_ssdCurrentLockState)
231bool _jsonTreeToString(_Inout_ string* out, _In_ SSDNode* tree, flags_t flags,
232 _Inout_opt_ SSDLockState* _ssdCurrentLockState);
233
236
237CX_C_END
JSON_OUT_FLAGS
JSON output formatting flags.
Definition jsonout.h:45
@ JSON_Minimal
Preset: Compact single-line output (minimal size)
Definition jsonout.h:63
@ JSON_Indent_Mask
Mask for extracting indent value (0-31 spaces)
Definition jsonout.h:47
@ JSON_Pretty
Preset: 4-space indent with newlines (readable output)
Definition jsonout.h:61
@ JSON_Compact
Omit spaces around { }, [ ], and : for compact output.
Definition jsonout.h:49
@ JSON_Windows_EOL
Force Windows-style line endings (CRLF) regardless of OS.
Definition jsonout.h:58
@ JSON_Unix_EOL
Force Unix-style line endings (LF) regardless of OS.
Definition jsonout.h:56
@ JSON_Single_Line
Do not insert newlines (causes indent to be ignored)
Definition jsonout.h:51
@ JSON_ASCII_Only
Escape all non-ASCII characters in output.
Definition jsonout.h:53
void jsonOutEnd(JSONOut **jo)
bool jsonOut(JSONOut *jo, const JSONParseEvent *ev)
JSONOut * jsonOutBegin(StreamBuffer *sb, flags_t flags)
void jsonStrEscape(string *out, strref val, flags_t flags)
Common types for JSON parsing and output.