| 139 | } |
| 140 | |
| 141 | bool jsonParseStrict(std::string const& _input, Json& _json, std::string* _errs /* = nullptr */) |
| 142 | { |
| 143 | try |
| 144 | { |
| 145 | _json = Json::parse( |
| 146 | // TODO: remove this in the next breaking release? |
| 147 | escapeNewlinesAndTabsWithinStringLiterals(_input), |
| 148 | /* callback */ nullptr, |
| 149 | /* allow exceptions */ true, |
| 150 | /* ignore_comments */true |
| 151 | ); |
| 152 | return true; |
| 153 | } |
| 154 | catch (Json::parse_error const& e) |
| 155 | { |
| 156 | if (_errs) |
| 157 | { |
| 158 | std::stringstream escaped; |
| 159 | for (char c: removeNlohmannInternalErrorIdentifier(e.what())) |
| 160 | if (std::isprint(c)) |
| 161 | escaped << c; |
| 162 | else |
| 163 | escaped << "\\x" + toHex(static_cast<uint8_t>(c)); |
| 164 | *_errs = escaped.str(); |
| 165 | } |
| 166 | return false; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | std::optional<Json> jsonValueByPath(Json const& _node, std::string_view _jsonPath) |
| 171 | { |