Skip to content

Commit 2603dc0

Browse files
authored
Merge pull request #11 from gallagher-tech/develop
use const nlohmann::json::at() not [] operator to avoid assert fail
2 parents 57b58a1 + c2889c8 commit 2603dc0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ga/json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace json {
1414
try {
1515
if ( keyOrPointer.empty() || keyOrPointer.at( 0 ) == '/' ) {
1616
// allow for json pointer paths - these are either empty or begin with '/'
17-
ret = json[ga::Json::json_pointer( keyOrPointer )].get<T>();
17+
ret = json.at(ga::Json::json_pointer( keyOrPointer )).get<T>();
1818
} else {
1919
// assume key is a normal key for a json object
20-
ret = json[keyOrPointer].get<T>();
20+
ret = json.at(keyOrPointer).get<T>();
2121
}
2222
} catch ( ... ) {
2323
// todo: log warning? accept an ostream& for logging?

src/ga/json_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ inline void from_json( const ga::Json& j, ga::mat4& m )
8080
// glm is column major - convert from row major
8181
for ( int r = 0; r < 4; ++r ) {
8282
for ( int c = 0; c < 4; ++c ) {
83-
_m[c][r] = j[r][c];
83+
_m[c][r] = j.at(r).at(c);
8484
}
8585
}
8686
} catch ( std::exception& e ) {

0 commit comments

Comments
 (0)