MCPcopy Create free account
hub / github.com/activeloopai/deeplake / build_nested_json

Function build_nested_json

cpp/deeplake_pg/extension_init.cpp:325–349  ·  view source on GitHub ↗

Build nested JSON from path: ["a", "b", "c"] with value "v" -> {"a": {"b": {"c": "v"}}}

Source from the content-addressed store, hash-verified

323
324// Build nested JSON from path: ["a", "b", "c"] with value "v" -> {"a": {"b": {"c": "v"}}}
325std::string build_nested_json(const std::vector<std::string>& path, const std::string& value)
326{
327 if (path.empty())
328 return "";
329
330 StringInfoData json;
331 initStringInfo(&json);
332
333 // Open braces for each level
334 for (size_t i = 0; i < path.size(); i++) {
335 appendStringInfo(&json, "{\"%s\":", path[i].c_str());
336 }
337
338 // Add value
339 appendStringInfo(&json, "\"%s\"", value.c_str());
340
341 // Close braces
342 for (size_t i = 0; i < path.size(); i++) {
343 appendStringInfoChar(&json, '}');
344 }
345
346 std::string result(json.data);
347 pfree(json.data);
348 return result;
349}
350
351// Transform ->> expressions into @> containment for JSONB index usage
352void transform_jsonb_arrow_quals(Node** nodeptr)

Callers 1

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected