-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
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
yaml string type not reserved & empty array and map not reserved #7
Comments
yaml string type not reservedfix by modify function at tojson.hpp#L75 inline nlohmann::json parse_scalar(const YAML::Node &node) {
int i;
double d;
bool b;
std::string s;
// string tag will be !
if (node.Tag() != "!") {
if (YAML::convert<int>::decode(node, i))
return i;
if (YAML::convert<double>::decode(node, d))
return d;
if (YAML::convert<bool>::decode(node, b))
return b;
}
if (YAML::convert<std::string>::decode(node, s))
return s;
return nullptr;
} empty array and map not reservedfix by modify function at tojson.hpp#L90 inline nlohmann::json yaml2json(const YAML::Node &root) {
nlohmann::json j{};
switch (root.Type()) {
case YAML::NodeType::Null:
break;
case YAML::NodeType::Scalar:
return parse_scalar(root);
case YAML::NodeType::Sequence:
j = nlohmann::json::array();
for (auto &&node : root)
j.emplace_back(yaml2json(node));
break;
case YAML::NodeType::Map:
j = nlohmann::json::object();
for (auto &&it : root)
j[it.first.as<std::string>()] = yaml2json(it.second);
break;
default:
break;
}
return j;
} |
Feel free to open a PR request, we can get this fix merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yaml string type not reserved
Types of numeric strings in yaml will be erased after conversion.
after convertion:
empty array and map not reserved
after convertion:
The text was updated successfully, but these errors were encountered: