Description
when use PCL library, I need write some data to json.
my code is some like:
"write special float value to json file":
float userFilterValue = std::numeric_limits<float>::quiet_NaN();
nlohmann::ordered_json ser;
ser["userFilterValue“] = userFilterValue;
std::ofstream("test.json") << ser.dump(2);
"read special float value to json file":
float userFilterValue2 = 0;
nlohmann::ordered_json ser2;
std::ifstream("test.json") >> ser2;
userFilterValue2 = (float) ser["userFilterValue“];
I found that the "test.json" file data:
{
"userFilterValue": null
}
Reproduction steps
I just want to serialize some special float value, such as "nan", "inf", "-inf"
but it throws exception wiht tips "type must be number, but is null"
Expected vs. actual results
when I write "nan", "inf" as float value, but it got "null"
Minimal code example
float userFilterValue = std::numeric_limits<float>::quiet_NaN();
nlohmann::ordered_json ser;
ser["userFilterValue“] = userFilterValue;
std::ofstream("test.json") << ser.dump(2);
nlohmann::ordered_json ser2;
std::ifstream("test.json") >> ser2;
float userFilterValue2 = (float) ser["userFilterValue“];
Error messages
type must be number, but is null
Compiler and operating system
visual studio 2019
Library version
3.10.4
Validation
Description
when use PCL library, I need write some data to json.
my code is some like:
I found that the "test.json" file data:
{ "userFilterValue": null }Reproduction steps
I just want to serialize some special float value, such as "nan", "inf", "-inf"
but it throws exception wiht tips "type must be number, but is null"
Expected vs. actual results
when I write "nan", "inf" as float value, but it got "null"
Minimal code example
Error messages
type must be number, but is nullCompiler and operating system
visual studio 2019
Library version
3.10.4
Validation
developbranch is used.