Esc

json_remove

procedureextensionsince 0.36.1Source
  • macOS: json_remove works on macOS
  • Linux: json_remove works on Linux
  • Windows: json_remove works on Windows
  • Wasm: json_remove works on Wasm

Removes the members of an object named key and frees them, keeping the order of the rest. A key that a document repeated has every copy removed, so json_get finds nothing afterwards. The result is whether there was anything to remove; anything but an object has nothing.

Signature

json_remove :: (object: *Json_Value, key: string) -> bool
key
the member name.
Example↗
object, _ := from_json(Json_Value, "{\"a\": 1, \"b\": 2}");
assert(json_remove(*object, "a"));
assert(!json_remove(*object, "a"));
assert(json_get(*object, "a") == null && json_count(*object) == 1);
free_json(*object);

See also