Skip to content
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

Easier Initialization of glz::json #133

Merged
merged 4 commits into from
Jan 21, 2023
Merged

Easier Initialization of glz::json #133

merged 4 commits into from
Jan 21, 2023

Conversation

mwalcott3
Copy link
Collaborator

@mwalcott3 mwalcott3 commented Jan 21, 2023

Modeled after the interface used in nlohmann https://github.com/nlohmann/json#json-as-first-class-data-type
Made in response to the discussion item #130 posted by @klemenpeganc

Allows for this:

glz::json_t json = {
   {"pi", 3.141},
   {"happy", true},
   {"name", "Niels"},
   {"nothing", nullptr},
   {"answer", {{"everything", 42.0}}},
   {"list", {1.0, 0.0, 2.0}},
   {"object", {
      {"currency", "USD"},
      {"value", 42.99}
   }}
};

Or this:

glz::json_t json;
json["pi"] = 3.14;
json["happy"] = true;
json["name"] = "Niels";
json["nothing"] = nullptr;
json["answer"]["everything"] = 42.0;
json["list"] = { 1.0, 0.0, 2.0 };
json["object"] = { {"currency", "USD"}, {"value", 42.99} };

@mwalcott3 mwalcott3 merged commit ab0f2f2 into main Jan 21, 2023
@mwalcott3 mwalcott3 deleted the generic_json branch January 21, 2023 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant