Taking more care on JSON i/o if keys are not available

parent 9ce1279c
...@@ -411,10 +411,12 @@ void ITAGeo::CMirrorImage::LoadFromJSONString( const std::string& sContent, std: ...@@ -411,10 +411,12 @@ void ITAGeo::CMirrorImage::LoadFromJSONString( const std::string& sContent, std:
v3MirrorNormal.SetValues( dMirrorNormal ); v3MirrorNormal.SetValues( dMirrorNormal );
//Get and set the polygon index //Get and set the polygon index
iPolygonIndex = ( int ) jnRoot.at( "polygon_index" ).as_int(); if( jnRoot.find( "polygon_index" ) != jnRoot.end() )
iPolygonIndex = ( int ) jnRoot.at( "polygon_index" ).as_int();
//Get and set the order number //Get and set the order number
iOrder = ( int ) jnRoot.at( "order" ).as_int(); if( jnRoot.find( "order" ) != jnRoot.end() )
iOrder = ( int ) jnRoot.at( "order" ).as_int();
#endif #endif
} }
...@@ -504,7 +506,8 @@ void ITAGeo::CSpecularReflection::LoadFromJSONString( const std::string& sConten ...@@ -504,7 +506,8 @@ void ITAGeo::CSpecularReflection::LoadFromJSONString( const std::string& sConten
CPropagationAnchor::LoadFromJSONString( sContent, pResourceManager ); CPropagationAnchor::LoadFromJSONString( sContent, pResourceManager );
iPolygonID = jnRoot.at( "polygon_id" ).as_int(); if( jnRoot.find("polygon_id") != jnRoot.end() )
iPolygonID = jnRoot.at( "polygon_id" ).as_int();
#endif #endif
} }
...@@ -810,8 +813,10 @@ void ITAGeo::CITADiffractionWedgeApertureBase::LoadFromJSONString( const std::st ...@@ -810,8 +813,10 @@ void ITAGeo::CITADiffractionWedgeApertureBase::LoadFromJSONString( const std::st
//Set the opposite wedge face normal //Set the opposite wedge face normal
v3OppositeWedgeFaceNormal.SetValues( dX, dY, dZ, dW ); v3OppositeWedgeFaceNormal.SetValues( dX, dY, dZ, dW );
int iMainWedgeFaceID = jnRoot.at( "main_wedge_face_id" ).as_int(); if( jnRoot.find("main_wedge_face_id") != jnRoot.end() )
int iOppositeWedgeFaceID = jnRoot.at( "opposite_wedge_face_id" ).as_int(); iMainWedgeFaceID = jnRoot.at( "main_wedge_face_id" ).as_int();
if( jnRoot.find( "opposite_wedge_face_id" ) != jnRoot.end() )
iOppositeWedgeFaceID = jnRoot.at( "opposite_wedge_face_id" ).as_int();
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment