vendredi 21 octobre 2016

How to create empty json object correctly using web.json in cpp?

I want to create following json request:

{
  "Value1":{},
  "Value2":"some string value"
}

to achieve this I have tried following code in cpp:

json::value &refRequest
json::value jRequest = json::value();
refRequest[requestKey::Value1] = json::value(json::value::object()); //for creating empty object
refRequest[requestKey::Value2] = json::value::string("some string");

but it gives output as:

{
  "Value1":},
  "Value2":"some string value"
}

if you observe, instead of returning empty object as {} it gives the output as } and this results in to malformed request. I am not sure where exactly I am going wrong, any help will would be appreciated. Thanks




Aucun commentaire:

Enregistrer un commentaire