| 10 | } |
| 11 | |
| 12 | bool JsonExporter::toJson(const Any& any, nlohmann::json& dst) const |
| 13 | { |
| 14 | auto const& type = any.castedType(); |
| 15 | |
| 16 | if(any.isString()) |
| 17 | { |
| 18 | dst = any.cast<std::string>(); |
| 19 | } |
| 20 | else if(type == typeid(int64_t)) |
| 21 | { |
| 22 | dst = any.cast<int64_t>(); |
| 23 | } |
| 24 | else if(type == typeid(uint64_t)) |
| 25 | { |
| 26 | dst = any.cast<uint64_t>(); |
| 27 | } |
| 28 | else if(type == typeid(double)) |
| 29 | { |
| 30 | dst = any.cast<double>(); |
| 31 | } |
| 32 | else if(type == typeid(std::vector<double>)) |
| 33 | { |
| 34 | dst = any.cast<std::vector<double>>(); |
| 35 | } |
| 36 | else if(type == typeid(std::vector<int>)) |
| 37 | { |
| 38 | dst = any.cast<std::vector<int>>(); |
| 39 | } |
| 40 | else if(type == typeid(std::vector<std::string>)) |
| 41 | { |
| 42 | dst = any.cast<std::vector<std::string>>(); |
| 43 | } |
| 44 | else if(type == typeid(std::vector<bool>)) |
| 45 | { |
| 46 | dst = any.cast<std::vector<bool>>(); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | auto it = to_json_converters_.find(type); |
| 51 | if(it != to_json_converters_.end()) |
| 52 | { |
| 53 | it->second(any, dst); |
| 54 | } |
| 55 | else |
| 56 | { |
| 57 | return false; |
| 58 | } |
| 59 | } |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | JsonExporter::ExpectedEntry JsonExporter::fromJson(const nlohmann::json& source) const |
| 64 | { |