mardi 24 mars 2020

How to convert string to rapid json value

I am using rapidjson library to encode and deconde the json.

I have received the string lets say string Str = "msisdn-123456789"; i want to covert this into a rapidjson value but it says parsing error. and value type is still kNullType

I am using below code snippest.

std::string Str = "msisdn-123456789";
rapidjson::Document newDoc;
newDoc.Parse(Str.c_str());
rapidjson::Value value(rapidjson::kNullType);
value.CopyFrom(newDoc, newDoc.GetAllocator());
cout << "Type of value" << static_cast<uint32_t>(value.GetType()) << endl; 

The output is kNullType (0) .

How can i convert string to rapidjson value ?

Aucun commentaire:

Enregistrer un commentaire