| 22 | private: |
| 23 | |
| 24 | static Boxed_Value from_json(const json::JSON &t_json) |
| 25 | { |
| 26 | switch( t_json.JSONType() ) { |
| 27 | case json::JSON::Class::Null: |
| 28 | return Boxed_Value(); |
| 29 | case json::JSON::Class::Object: |
| 30 | { |
| 31 | std::map<std::string, Boxed_Value> m; |
| 32 | |
| 33 | for (const auto &p : t_json.object_range()) |
| 34 | { |
| 35 | m.insert(std::make_pair(p.first, from_json(p.second))); |
| 36 | } |
| 37 | |
| 38 | return Boxed_Value(m); |
| 39 | } |
| 40 | case json::JSON::Class::Array: |
| 41 | { |
| 42 | std::vector<Boxed_Value> vec; |
| 43 | |
| 44 | for (const auto &p : t_json.array_range()) |
| 45 | { |
| 46 | vec.emplace_back(from_json(p)); |
| 47 | } |
| 48 | |
| 49 | return Boxed_Value(vec); |
| 50 | } |
| 51 | case json::JSON::Class::String: |
| 52 | return Boxed_Value(t_json.to_string()); |
| 53 | case json::JSON::Class::Floating: |
| 54 | return Boxed_Value(t_json.to_float()); |
| 55 | case json::JSON::Class::Integral: |
| 56 | return Boxed_Value(t_json.to_int()); |
| 57 | case json::JSON::Class::Boolean: |
| 58 | return Boxed_Value(t_json.to_bool()); |
| 59 | } |
| 60 | |
| 61 | throw std::runtime_error("Unknown JSON type"); |
| 62 | } |
| 63 | |
| 64 | static Boxed_Value from_json(const std::string &t_json) |
| 65 | { |
nothing calls this directly
no test coverage detected