@@ -138,8 +138,10 @@ std::string replace(const std::string &str, const char from, const char to)
138138// Stringify JSON
139139std::string stringify (const json::value &j)
140140{
141- const std::string tmp = j.dump ();
142- return j.has <json::string>()
141+ std::ostringstream oss;
142+ j.write (oss);
143+ const std::string tmp = oss.str ();
144+ return j.holds <json::string>()
143145 ? tmp.substr (1 , tmp.size ()-2 )
144146 : tmp;
145147}
@@ -235,8 +237,8 @@ const std::string &nameGNDS(
235237 // As-is, directly as stipulated in the key in the JSON spec, except
236238 // that we allow a "name" entry in the key's value to override the key.
237239 return keyval.second .has (" name" )
238- ? keyval.second [" name" ].get <json::string>()
239- : keyval.first ;
240+ ? (std::string &) keyval.second [" name" ].get <json::string>()
241+ : (std::string &) keyval.first ;
240242}
241243
242244// nameField
@@ -376,7 +378,7 @@ void getClassMetadata(
376378 for (const auto &field : j) {
377379 if (beginsin (field.first , " //" ))
378380 continue ;
379- if (!field.second .has <json::object>())
381+ if (!field.second .holds <json::object>())
380382 continue ;
381383 const json::object &metaRHS = field.second .get <json::object>();
382384
@@ -395,7 +397,7 @@ void getClassMetadata(
395397
396398 // Has default?
397399 m.defaultValue = " " ;
398- if (metaRHS.has (" default" ) && !metaRHS[" default" ].is_null ()) {
400+ if (metaRHS.has (" default" ) && !metaRHS[" default" ].holds <json::null> ()) {
399401 m.defaultValue = stringify (metaRHS[" default" ]);
400402 // Apply the "changes.json" change, if any, to the given value
401403 const auto it = specs.mapMetaDefault .find (m.defaultValue );
@@ -452,7 +454,7 @@ void getClassChildren(
452454 for (const auto &field : j) {
453455 if (beginsin (field.first , " //" ))
454456 continue ;
455- if (!field.second .has <json::object>())
457+ if (!field.second .holds <json::object>())
456458 continue ;
457459 const json::object &elemRHS = field.second .get <json::object>();
458460
@@ -549,7 +551,7 @@ void getClassVariants(
549551 continue ;
550552
551553 // Is it a choice child?
552- if (!field.second .has <json::object>())
554+ if (!field.second .holds <json::object>())
553555 continue ;
554556 const json::object &elemRHS = field.second .get <json::object>();
555557 const std::string × = getTimes (per,field.first ,elemRHS);
@@ -569,7 +571,7 @@ void getClassVariants(
569571 continue ;
570572
571573 // Is it a choice child?
572- if (!field.second .has <json::object>())
574+ if (!field.second .holds <json::object>())
573575 continue ;
574576 const json::object &elemRHS = field.second .get <json::object>();
575577 const std::string × = getTimes (per,field.first ,elemRHS);
@@ -712,7 +714,7 @@ void readChangesFile(const std::string &file, InfoSpecs &specs)
712714
713715 // Changes to name?
714716 if (jchanges.has (" name" ))
715- for (const auto &item : jchanges[" name" ].items ())
717+ for (const auto &item : jchanges[" name" ].pairs ())
716718 if (!isComment (item.first ))
717719 specs.mapName .insert (
718720 pair (item.first , item.second .get <json::string>())
@@ -723,14 +725,14 @@ void readChangesFile(const std::string &file, InfoSpecs &specs)
723725
724726 // from/to pairs for "type"
725727 if (metadata.has (" type" ))
726- for (const auto &item : metadata[" type" ].items ())
728+ for (const auto &item : metadata[" type" ].pairs ())
727729 if (!isComment (item.first ))
728730 specs.mapMetaType .insert (
729731 pair (item.first ,item.second .get <json::string>())
730732 );
731733 // from/to pairs for "default"
732734 if (metadata.has (" default" ))
733- for (const auto &item : metadata[" default" ].items ())
735+ for (const auto &item : metadata[" default" ].pairs ())
734736 if (!isComment (item.first ))
735737 specs.mapMetaDefault .insert (
736738 pair (item.first ,item.second .get <json::string>())
@@ -749,17 +751,17 @@ void printSingletons(const std::string &file)
749751 for (const auto &item : jfile) {
750752 if (beginsin (item.first , " //" ))
751753 continue ;
752- if (!item.second .has <json::object>())
754+ if (!item.second .holds <json::object>())
753755 continue ;
754756 const json::object &rhs = item.second .get <json::object>();
755757
756758 if (!isClass (item))
757759 continue ;
758760
759761 const bool hasdata =
760- (rhs.has (" string" ) && !rhs[" string" ].is_null ()) ||
761- (rhs.has (" vector" ) && !rhs[" vector" ].is_null ()) ||
762- (rhs.has (" bodyText" ) && !rhs[" bodyText" ].is_null ());
762+ (rhs.has (" string" ) && !rhs[" string" ].holds <json::null> ()) ||
763+ (rhs.has (" vector" ) && !rhs[" vector" ].holds <json::null> ()) ||
764+ (rhs.has (" bodyText" ) && !rhs[" bodyText" ].holds <json::null> ());
763765
764766 const json::object metadata = getMetadataJSON (rhs);
765767 const json::object children = getChildrenJSON (rhs);
@@ -1114,9 +1116,9 @@ void getClass(
11141116
11151117 // data-node information
11161118 const bool
1117- str = classRHS.has (" string" ) && !classRHS[" string" ].is_null (),
1118- vec = classRHS.has (" vector" ) && !classRHS[" vector" ].is_null (),
1119- body = classRHS.has (" bodyText" ) && !classRHS[" bodyText" ].is_null ();
1119+ str = classRHS.has (" string" ) && !classRHS[" string" ].holds <json::null> (),
1120+ vec = classRHS.has (" vector" ) && !classRHS[" vector" ].holds <json::null> (),
1121+ body = classRHS.has (" bodyText" ) && !classRHS[" bodyText" ].holds <json::null> ();
11201122 assert (int (str) + int (vec) + int (body) <= 1 ); // no more than one
11211123
11221124 per.isDataString = str;
0 commit comments