Skip to content

Commit 79f2062

Browse files
committed
add jsonwriter_datatype_raw type for jsonwriter_variant()
1 parent 2d0fad3 commit 79f2062

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

jsonwriter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ enum jsonwriter_status jsonwriter_variant(jsonwriter_handle d, void *data) {
415415
case jsonwriter_datatype_bool:
416416
rc = jsonwriter_bool(d, jv.value.i ? 1 : 0);
417417
break;
418+
case jsonwriter_datatype_raw:
419+
if(jv.value.str)
420+
rc = jsonwriter_write_raw(d, jv.value.str, strlen(jv.value.str));
421+
else
422+
rc = jsonwriter_null(d);
423+
break;
418424
}
419425
if(d->after_to_jsw_variant)
420426
d->after_to_jsw_variant(data, &jv);

jsonwriter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ extern "C" {
9494
jsonwriter_datatype_string = 1,
9595
jsonwriter_datatype_integer = 2,
9696
jsonwriter_datatype_float = 3,
97-
jsonwriter_datatype_bool = 4
97+
jsonwriter_datatype_bool = 4,
98+
jsonwriter_datatype_raw = 5, // already stringified, output verbatim
9899
// possible to do:
99100
// array
100101
// object

0 commit comments

Comments
 (0)