aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/writer/README
blob: 6e6f75465822076efd2199b632132fd2cf757d9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
JSON writer with no external dependencies, producing output 
where HTML special characters are always escaped. 
 
Use it like this: 
 
    #include <library/cpp/json/writer/json.h>
    ... 
 
    NJsonWriter::TBuf json; 
    json.BeginList() 
        .WriteString("<script>") 
        .EndList(); 
    Cout << json.Str(); // output: ["\u003Cscript\u003E"] 
 
For compatibility with legacy formats where object keys 
are not quoted, use CompatWriteKeyWithoutQuotes: 
     
    NJsonWriter::TBuf json; 
    json.BeginObject() 
        .CompatWriteKeyWithoutQuotes("r").WriteInt(1) 
        .CompatWriteKeyWithoutQuotes("n").WriteInt(0) 
    .EndObject(); 
    Cout << json.Str(); // output: {r:1,n:0}