-
What is the issue you have?
When exporting to CBOR, in some cases the file is not properly formatted
-
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
using json = nlohmann::basic_json<std::map, std::vector, std::string, bool, int32_t, uint32_t, float>;
using json_input_adaper = nlohmann::detail::input_adapter;
using json_output_adaper = nlohmann::detail::output_adapter<char>;
auto jsNew = json();
auto array = json::array();
for (int i = 0; i < 1099; ++i) {
array.push_back(0.0f);
}
jsNew["t"] = array;
std::ofstream ofs("file.cbor", std::ios_base::binary);
json::to_cbor(jsNew, json_output_adaper{ofs});
ofs.close();
std::ifstream ifs("file.cbor", std::ios_base::binary);
const auto load = json::from_cbor(json_input_adaper{ifs});
-
What is the expected behavior?
The cbor file should load properly
-
And what is the actual behavior instead?
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
-
Which compiler and operating system are you using? Is it a supported compiler?
OSX, Xcode 9.4.1 clang
-
Did you use a released version of the library or the version from the develop branch?
release
-
If you experience a compilation error: can you compile and run the unit tests?
I think the problem comes from the CBOR export. My floating point type is float, not double.
In function write_cbor, writing a floating point value forces the type to be 0xFB, even for floats. This works for double, but should be 0xFA for floats.
What is the issue you have?
When exporting to CBOR, in some cases the file is not properly formatted
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
What is the expected behavior?
The cbor file should load properly
And what is the actual behavior instead?
JSON_THROW(parse_error::create(110, chars_read, "unexpected end of input"));
Which compiler and operating system are you using? Is it a supported compiler?
OSX, Xcode 9.4.1 clang
Did you use a released version of the library or the version from the
developbranch?release
If you experience a compilation error: can you compile and run the unit tests?
I think the problem comes from the CBOR export. My floating point type is float, not double.
In function write_cbor, writing a floating point value forces the type to be 0xFB, even for floats. This works for double, but should be 0xFA for floats.