Category : json

I would like to convert cbor into json using the C++ jsoncons library (https://github.com/danielaparker/jsoncons/blob/master/doc/ref/cbor/cbor.md). But when I print the result to console some entries are weird. My Code: const std::vector<uint8_t> data1 = { 0xa4, 0x01, 0x58 , 0x65 , 0x83 , 0x43 , 0xa1 , 0x01 , 0x0a , 0xa1 , 0x05 , 0x4d , ..

Read more

What is the proper way to open a file with boost::property_tree::json_parser::read_json Current tree: boost::property_tree::ptree config; boost::property_tree::json_parser::read_json("conf/file.json", config); But I get the error that it cannot find the file terminating with uncaught exception of type boost::wrapexceptboost::property_tree::json_parser::json_parser_error: conf/file.json: cannot open file How would I go on about copying the file into the device and being able to ..

Read more

I have one application were I need to convert XML to JSON and send Json Data to Cloud using REST API in C++. I googled but I find very few resources , found these useful link https://github.com/Cheedoong/xml2json I want to confirm whether it is possible to convert XML to JSON format easily in C++. As ..

Read more

Please find the below code. template<typename T> T GetValueFromDataType(Value &value) { T jsonValue; if (value.IsString()) { assert(value.IsString()); jsonValue = value.GetString(); //here error is showing return jsonValue ; } else if (value.IsInt()) { assert(value.IsInt()); jsonValue = value.GetInt(); return jsonValue; } else if (value.IsDouble()) { assert(value.IsDouble()); jsonValue= value.GetDouble(); return jsonValue; } else if (value.IsBool()) { assert(value.IsBool()); jsonValue ..

Read more

I have problems with inserting rapidjson::Document into rapidjson::Value(rapidjson::kObjectType). I tried almost everything that I found on the internet, but it works strange in some cases. I have object which I have serialized into rapidjson::Document and return rapidjson::Document* after that (when I converted it to string, it looks fine), but when I do array.PushBack(returnedJson, array.GetAllocator()) it ..

Read more

$ [email protected] autojsoncxx % python autojsoncxx.py –input=persondef.json –output=person.hpp Traceback (most recent call last): File "autojsoncxx.py", line 93, in <module> NOESCAPE_CHARACTERS = bytes(string.digits + string.ascii_letters + ‘ ‘, encoding=’utf8’) TypeError: str() takes at most 1 argument (2 given) I am trying to use autojsoncxx. Was able to follow the steps to run the following: cake . ..

Read more

is it possible to insert the value of a variable inside a raw string? I need to insert the value of my variable "stringa" as a JSON value but my variable contains a lot of escape characters. try to better explain: nlohmann::json j; //create the json std::string one = "hello"; j[firstObj] = one; std::ifstream conf(confPath, ..

Read more