Jsoncpp is an open source tool for parsing and generating JSON in C + +. If your C + + program needs to parse or generate JSON, it makes the process simple!
However, today, when using jsoncpp to generate JSON, the error was reported, obviously this is not my program's problem.
Test.cpp:In function ' std::string createjsondata () ': Test.cpp:41:error:conversion from ' long-long int ' to ' const JSON::V Alue ' is ambiguousinclude/json/value.h:205:note:candidates are:json::value::value (bool) include/json/value.h:188: Note: json::value::value (const char*) <near match>include/json/value.h:187:note: json::value::value (double) Include/json/value.h:186:note: json::value::value (json::uint) Include/json/value.h:185:note: Json::value::value (json::int) Include/json/value.h:184:note: json::value::value (Json::valuetype) <near Match>
This error occurs when my data to generate JSON contains a long type! If you change long to int or double, you can compile.
According to the error message, it is clear that Jsoncpp does not implement a new interface in the insert data that has a long class . Therefore, Jsoncpp cannot process new data containing the long class.
After searching the internet, someone explained why Jsoncpp does not support the interface of Long data, " why is there no 64-bit integer in Jsoncpp?" JSON originates from JavaScript, in JS, the representation of the number may be different from the high-level language, if a number 32 bits can not say that JS should be all in a double, so that JS large integer is actually a double, This can also explain why the 64 conversion method is not provided in the jsoncpp. "
I tried to change the long type to a double type, but in the resulting JSON string, the data for long-double is a decimal number after the digit. It's not what I want!
Jsoncpp is a good tool, but can't handle the long type is the place where it is in the ointment.
Hope that the subsequent upgrade can solve this problem! ~
Jsoncpp cannot handle long type data