JsonCpp: How to get en empty object in a Json::Value?

AlexV picture AlexV · Apr 24, 2015 · Viewed 7.8k times · Source

I have an external library that receive a Json::Value as a parameter. It will then output a string containing a JSON structure with my passed Json::Value somewhere in that structure.

I'm trying to put an empty object {} in that Json::Value with JsonCpp.

Ultimately I'm trying to parse that empty JSON object from a std::string that contain "{}" and I need that in a Json::Value.

When I declare a Json::Value and do nothing with it and pass it to my library, I get NULL instead of {}...

Answer

InTERpLAY picture InTERpLAY · Aug 28, 2017

It may be helpful for someone: In current ver. that i'm using - 1.8.2, you can get empty Object like this:

Json::Value root;
root = Json::objectValue;