27 #include <rapidjson/rapidjson.h>
28 #include <boost/optional.hpp>
33 inline void from_json(
const rapidjson::Value& value, std::string& x) {
34 x = value.GetString();
37 inline void from_json(
const rapidjson::Value& value, int32_t& x) {
41 inline void from_json(
const rapidjson::Value& value, int64_t& x) {
45 inline void from_json(
const rapidjson::Value& value,
double& x) {
46 x = value.GetDouble();
49 inline void from_json(
const rapidjson::Value& value,
bool& x) {
53 inline void from_json(
const rapidjson::Value& value,
54 std::shared_ptr<std::vector<unsigned char>>& x) {
55 std::string s = value.GetString();
56 x = std::make_shared<std::vector<unsigned char>>(s.begin(), s.end());
60 inline void from_json(
const rapidjson::Value& value, boost::optional<T>& x) {
62 from_json(value, result);
67 inline void from_json(
const rapidjson::Value& value,
68 std::map<std::string, T>& results) {
69 for (rapidjson::Value::ConstMemberIterator itr = value.MemberBegin();
70 itr != value.MemberEnd(); ++itr) {
72 from_json(itr->name, key);
73 from_json(itr->value, results[key]);
78 inline void from_json(
const rapidjson::Value& value, std::vector<T>& results) {
79 for (rapidjson::Value::ConstValueIterator itr = value.Begin();
80 itr != value.End(); ++itr) {
82 from_json(*itr, result);
83 results.emplace_back(std::move(result));
88 inline T parse(
const rapidjson::Value& value,
const std::string& name) {
90 rapidjson::Value::ConstMemberIterator itr = value.FindMember(name.c_str());
91 if (itr != value.MemberEnd()) {
92 from_json(itr->value, result);
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24