gregjesl/simpleson

README.md Outdated?

OAkyildiz opened this issue · 2 comments

Examples under the ##Quickstart seem to be outdated. Is json::key_value_pair replaced with jobject?

Pretty sure this is not the kosher way to interact with your library (or not what you wanted to demonstrate in the README) but it works.

  /*JSON TEST*/
// Create the input
std::string input = "{ \"hello\": \"world\" }";

// Parse the input
json::jobject result = json::jobject::parse(input);

// Get a value
std::string value = (std::string)result["hello"];

// Add entry
// json::kvp item;
// item.first = "new_key";
// item.second = json::jtype::jstring(123.4);
json::jobject item;
item["new_value"]= 123.4;
result += item;

// Serialize the new object
std::string serial = (std::string)result;
cout << serial<< endl;```

Good catch, the readme is in fact outdated. I'll push an update with some sample code from the unit tests.