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

parent 9ce1279c
......@@ -411,9 +411,11 @@ void ITAGeo::CMirrorImage::LoadFromJSONString( const std::string& sContent, std:
v3MirrorNormal.SetValues( dMirrorNormal );
//Get and set the polygon index
if( jnRoot.find( "polygon_index" ) != jnRoot.end() )
iPolygonIndex = ( int ) jnRoot.at( "polygon_index" ).as_int();
//Get and set the order number
if( jnRoot.find( "order" ) != jnRoot.end() )
iOrder = ( int ) jnRoot.at( "order" ).as_int();
#endif
......@@ -504,6 +506,7 @@ void ITAGeo::CSpecularReflection::LoadFromJSONString( const std::string& sConten
CPropagationAnchor::LoadFromJSONString( sContent, pResourceManager );
if( jnRoot.find("polygon_id") != jnRoot.end() )
iPolygonID = jnRoot.at( "polygon_id" ).as_int();
#endif
......@@ -810,8 +813,10 @@ void ITAGeo::CITADiffractionWedgeApertureBase::LoadFromJSONString( const std::st
//Set the opposite wedge face normal
v3OppositeWedgeFaceNormal.SetValues( dX, dY, dZ, dW );
int iMainWedgeFaceID = jnRoot.at( "main_wedge_face_id" ).as_int();
int iOppositeWedgeFaceID = jnRoot.at( "opposite_wedge_face_id" ).as_int();
if( jnRoot.find("main_wedge_face_id") != jnRoot.end() )
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
}
......
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