| 62 | } |
| 63 | |
| 64 | std::optional<std::string> QueryJson(const std::string &jsonStr, |
| 65 | const std::string &query) |
| 66 | { |
| 67 | #ifdef JSONPATH_SUPPORT |
| 68 | try { |
| 69 | auto json = jsoncons::json::parse(jsonStr); |
| 70 | auto result = jsoncons::jsonpath::json_query(json, query); |
| 71 | return result.as_string(); |
| 72 | } catch (const jsoncons::json_exception &) { |
| 73 | return {}; |
| 74 | } catch (const jsoncons::json_errc &) { |
| 75 | return {}; |
| 76 | } |
| 77 | #else |
| 78 | return {}; |
| 79 | #endif |
| 80 | } |
| 81 | |
| 82 | std::optional<std::string> AccessJsonArrayIndex(const std::string &jsonStr, |
| 83 | const int index) |
no outgoing calls
no test coverage detected