Created
April 14, 2016 07:52
-
-
Save matt-42/def26a8f4ac7ddee7f60af4bf1aaff37 to your computer and use it in GitHub Desktop.
iod json parsing of nested objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iod/json.hh> | |
// Run iod_generate_symbols test.cc symbols.hh | |
#include "symbols.hh" | |
int main() | |
{ | |
std::string str = R"({"name": "x", "position": { "x": 10, "y": 11, "z": 12}})"; | |
using namespace s; | |
auto o = iod::D(_name = std::string(), | |
_position = iod::D(_x = int(), _y = int(), _z = int())); | |
json_decode(o, str); | |
assert(o.name == "x"); | |
assert(o.position.x == 10); | |
assert(o.position.y == 11); | |
assert(o.position.z == 12); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment