What is the issue you have?
When deserializing the following json from a file on macOS
{
"SaveAllImages": true,
"SaveOnlyFailedImages": false,
"RedThreshold": 215,
"MaxRedThreshold": 255,
"BlueThreshold": 215,
"MaxBlueThreshold": 255,
"BlobFilterArea": true,
"BlobMinAreaPx": 2000,
"BlobMaxAreaPx": 6000,
"BlobMinThreshold": 10,
"BlobMaxThreshold": 10000,
"BlobFilterCircularity": true,
"BlobMinCircularity": 0.6,
"BlobMaxCircularity": 1.0
}
I get an object (which is expected)
{
"SaveAllImages": true,
"SaveOnlyFailedImages": false,
"RedThreshold": 215,
"MaxRedThreshold": 255,
"BlueThreshold": 215,
"MaxBlueThreshold": 255,
"BlobFilterArea": true,
"BlobMinAreaPx": 2000,
"BlobMaxAreaPx": 6000,
"BlobMinThreshold": 10,
"BlobMaxThreshold": 10000,
"BlobFilterCircularity": true,
"BlobMinCircularity": 0.6,
"BlobMaxCircularity": 1.0
}
When I run this same code, using the same json file in a docker container running Debian I get an array (unexpected)
[{
"SaveAllImages": true,
"SaveOnlyFailedImages": false,
"RedThreshold": 215,
"MaxRedThreshold": 255,
"BlueThreshold": 215,
"MaxBlueThreshold": 255,
"BlobFilterArea": true,
"BlobMinAreaPx": 2000,
"BlobMaxAreaPx": 6000,
"BlobMinThreshold": 10,
"BlobMaxThreshold": 10000,
"BlobFilterCircularity": true,
"BlobMinCircularity": 0.6,
"BlobMaxCircularity": 1.0
}]
This of course causes an exception be to thrown:
[json.exception.type_error.306] cannot use value() with array
Can you provide a small but working code example?
Reading the file
std::ifstream file{ config };
if ( !file.is_open( ) )
{
throw create_error(
"Get configuration error: Failed to open file {}\n", config );
}
// This succeeds.
try { return json::parse( file ); }
catch( const json::exception& ex )
{
throw create_error(
"Get configuration error: Deserialization failed {}\n", ex.what( ) );
}
Reading a property
// This throws the exception specified above.
double threshold{ json_reader.value( "BlueThreshold", 215.0 ) };
What is the expected behavior?
I expect deserialization to be the same for both platforms.
And what is the actual behavior instead?
On macOS I get a json object back, on Linux I get an array back.
Which compiler and operating system are you using?
Which version of the library did you use?
I'm currently exposing the json file to the container via osxfs
What is the issue you have?
When deserializing the following json from a file on macOS
I get an object (which is expected)
When I run this same code, using the same json file in a docker container running Debian I get an array (unexpected)
This of course causes an exception be to thrown:
Can you provide a small but working code example?
Reading the file
Reading a property
What is the expected behavior?
I expect deserialization to be the same for both platforms.
And what is the actual behavior instead?
On macOS I get a json
objectback, on Linux I get anarrayback.Which compiler and operating system are you using?
Compiler: g++ (Linux) and clang (macOS)
Operating system:
Host: macOS Catalina
Container: Debian
Which version of the library did you use?
developbranchI'm currently exposing the json file to the container via osxfs