-
-
Save Rapptz/0ebcb6dfdff14fd85ebb to your computer and use it in GitHub Desktop.
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
/* | |
Given a JSON object: | |
{ | |
"id": "144843276418023424", | |
"position": -1, | |
"colour": 0, | |
"name": "test", | |
"managed": false | |
} | |
*/ | |
struct rgb_colour { | |
unsigned char r, g, b; | |
rgb_colour(int x) { | |
// unpack x into r g b bytes | |
} | |
}; | |
struct cool { | |
rgb_colour colour; | |
std::string name; | |
std::string id; | |
int position; | |
bool managed; | |
}; | |
// deserialisation begins here | |
struct cool_schema { | |
template<typename Algo> | |
void operator()(Algo& algo, cool& c) const { | |
algo.member("name", c.name); | |
algo.member("id", c.id); | |
algo.member("position", c.position); | |
algo.member("managed", c.managed); | |
// how2do for rgb_colour? | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment