We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@royfalk okay - WFM; but let's file an issue to migrate to the Boost one once we support the appropriate Boost version.
Originally posted by @BenjamenMeyer in #686 (comment)
The text was updated successfully, but these errors were encountered:
@BenjamenMeyer
I think it's time. We've had JSON support for more than two years now.
Boost JSON was released in 1.75 on December 2020.
Boost JSON parsing:
const std::string json_text; boost::json::value json_value = boost::json::parse(json_text); boost::json::object root = json_value.get_object(); std::string string_key = boost::json::value_to<std::string>(root.at("string_key")); int int_key = boost::json::value_to<int>(root.at("int_key")); double double_key = boost::json::value_to<double>(root.at("double_key")); bool bool_key = boost::json::value_to<bool>(root.at("bool_key"));
Singleson parsing:
const std::string json_text; std::vector<std::string> units = json::parsing::parse_array(json_text.c_str()); // Iterate over root for (const std::string &unit_text : units) { json::jobject unit = json::jobject::parse(unit_text); std::map<std::string, std::string> unit_attributes; for (const std::string &key : keys) { // For some reason, parser adds quotes if(unit.has_key(key)) { const std::string attribute = unit.get(key); const std::string stripped_attribute = attribute.substr(1, attribute.size() - 2); unit_attributes[key] = stripped_attribute; ...
Two things to note in the code comparison above:
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
@royfalk okay - WFM; but let's file an issue to migrate to the Boost one once we support the appropriate Boost version.
Originally posted by @BenjamenMeyer in #686 (comment)
The text was updated successfully, but these errors were encountered: