Parse json_str into Document. Return false for errors.
| 286 | |
| 287 | /// Parse json_str into Document. Return false for errors. |
| 288 | static bool ParseStringVal(FunctionContext* ctx, const StringVal& json_str, |
| 289 | JsonUdfDocument* doc) { |
| 290 | StringValStream stream(&json_str); |
| 291 | RETURN_IF_OOM(doc->ParseStream(stream), false); |
| 292 | if (doc->HasParseError()) { |
| 293 | string msg = Substitute("Failed to parse json at position $0 since: $1." |
| 294 | " Json string:\n$2", doc->GetErrorOffset(), |
| 295 | GetParseError_En(doc->GetParseError()), AnyValUtil::ToString(json_str)); |
| 296 | ctx->AddWarning(msg.c_str()); |
| 297 | return false; |
| 298 | } |
| 299 | return true; |
| 300 | } |
| 301 | |
| 302 | // Initial capacity of the BFS queue used in GetJsonObjectImpl |
| 303 | static const int INITIAL_QUEUE_CAPACITY = 64; |
no test coverage detected