| 157 | } |
| 158 | |
| 159 | std::shared_ptr<JSONNode> parseJSON(const String & json) |
| 160 | { |
| 161 | ParserImpl::Element document; |
| 162 | ParserImpl p; |
| 163 | |
| 164 | if (!p.parse(json, document)) |
| 165 | { |
| 166 | constexpr size_t max_length = 128LU; |
| 167 | throw Exception( |
| 168 | ErrorCodes::INCORRECT_DATA, |
| 169 | "Failed to parse JSON from the string '{}'{}.", |
| 170 | escapeString(json.substr(0, max_length)), |
| 171 | json.size() >= max_length ? "... (truncated)" : ""); |
| 172 | } |
| 173 | |
| 174 | auto root = std::make_shared<JSONNode>(); |
| 175 | traverse(document, root); |
| 176 | return root; |
| 177 | } |
| 178 | |
| 179 | char generateRandomCharacter(pcg64 & rnd, const std::string_view & charset) |
| 180 | { |