Fixing a problem if JSON node does not exist

parent 7a62cf58
...@@ -195,9 +195,12 @@ void ITAGeo::CEmitter::LoadFromJSONString( const std::string& sContent, std::sha ...@@ -195,9 +195,12 @@ void ITAGeo::CEmitter::LoadFromJSONString( const std::string& sContent, std::sha
//Set the orientation //Set the orientation
qOrient.SetValues( dOrientation ); qOrient.SetValues( dOrientation );
std::string sDirectivityID = jnRoot.at( "directivity_id" ).as_string(); if( jnRoot.find( "directivity_id" ) != jnRoot.end() )
if( pResourceManager && pResourceManager->HasDirectivity( sDirectivityID ) ) {
pDirectivity = pResourceManager->GetDirectivity( sDirectivityID ); std::string sDirectivityID = jnRoot.at( "directivity_id" ).as_string();
if( pResourceManager && pResourceManager->HasDirectivity( sDirectivityID ) )
pDirectivity = pResourceManager->GetDirectivity( sDirectivityID );
}
#endif #endif
} }
...@@ -304,9 +307,13 @@ void ITAGeo::CSensor::LoadFromJSONString( const std::string& sContent, std::shar ...@@ -304,9 +307,13 @@ void ITAGeo::CSensor::LoadFromJSONString( const std::string& sContent, std::shar
//Set the orientation //Set the orientation
qOrient.SetValues( dOrientation ); qOrient.SetValues( dOrientation );
std::string sDirectivityID = ( std::string ) jnRoot.at( "directivity_id" ).as_string();
if( pResourceManager->HasDirectivity( sDirectivityID ) ) if( jnRoot.find( "directivity_id" ) != jnRoot.end() )
pDirectivity = pResourceManager->GetDirectivity( sDirectivityID ); {
std::string sDirectivityID = ( std::string ) jnRoot.at( "directivity_id" ).as_string();
if( pResourceManager->HasDirectivity( sDirectivityID ) )
pDirectivity = pResourceManager->GetDirectivity( sDirectivityID );
}
#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