我有一个示例文件"sample.json",其中包含3个json对象
{ "A": "something1", "B": "something2", "C": "something3", "d": "something4"} { "A": "something5", "B": "something6", "C": "something7", "d": "something8"} { "A": "something9", "B": "something10", "C": "something11", "d": "something12"}
(上面的文件中没有换行符)
我想用jsoncpp读取所有三个json对象.
我能够读取第一个对象但不能读取它.
这是我的代码的相关部分
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
std::ifstream test("sample.json", std::ifstream::binary);
bool parsingSuccessful = reader.parse(test, root, false);
int N = 3;
if (parsingSuccessful)
{
for (size_t i = 0; i < N; i++)
{
std::string A= root.get("A", "ASCII").asString();
std::string B= root.get("B", "ASCII").asString();
std::string C= …Run Code Online (Sandbox Code Playgroud)