Parse string to UniValue or throw runtime_error if string contains invalid JSON */
| 399 | |
| 400 | /** Parse string to UniValue or throw runtime_error if string contains invalid JSON */ |
| 401 | static UniValue Parse(std::string_view raw, ParamFormat format = ParamFormat::JSON) |
| 402 | { |
| 403 | UniValue parsed; |
| 404 | if (!parsed.read(raw)) { |
| 405 | if (format != ParamFormat::JSON_OR_STRING) throw std::runtime_error(tfm::format("Error parsing JSON: %s", raw)); |
| 406 | return UniValue(std::string(raw)); |
| 407 | } |
| 408 | return parsed; |
| 409 | } |
| 410 | |
| 411 | namespace rpc_convert |
| 412 | { |