-
Notifications
You must be signed in to change notification settings - Fork 211
Open
Description
After the recent fix parsing YAML into the glz::generic started to compile, but there is still problems with it, I have made some test cases:
#include <string>
#include <print>
#include <glaze/glaze.hpp>
#include <glaze/yaml.hpp>
void testYAML(std::string yaml)
{
std::print(R"(====================Source:
{}
====================Result:
)", yaml);
glz::generic parsed;
auto ec=glz::read_yaml<glz::opts{.error_on_unknown_keys = false}>(parsed, yaml);
if(ec)
std::print("Error: {}", glz::format_error(ec, yaml));
else
{
std::string yaml2;
void(glz::write_yaml(parsed, yaml2));
std::print("{}", yaml2);
}
std::print("\n");
}
int main(int nargs,char *args[])
{
testYAML(R"({"name": "Alice", "age": 30})");
testYAML(R"({"name": "Alice",
"age": 30})");
testYAML("---\nname: Alice");
return 0;
}From this program I am getting this output:
====================Source:
{"name": "Alice", "age": 30}
====================Result:
age:
30name:
Alice
====================Source:
{"name": "Alice",
"age": 30}
====================Result:
Error: 1:18: syntax_error
{"name": "Alice",
"age": 30}
^
====================Source:
---
name: Alice
====================Result:
name
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels