JSONCPP Writing to files

后端 未结 5 1917
我在风中等你
我在风中等你 2020-12-24 02:26

JSONCPP has a writer, but all it seems to do is get info from the parser and then output it into a string or a stream. How do I make it alter or create new objects, arrays,

5条回答
  •  执念已碎
    2020-12-24 02:55

    First, you have to create the desired JSON::Value. You should look at all the constructors (first). To create the necessary hierarchies, see append and the operator[] overloads; there are overloads for both array indices and string keys for objects.

    One way to write the JSON value back out is using StyledStreamWriter::write and ofstream.

    See cegprakash's answer for how to write it.

提交回复
热议问题