What does null do in a JSON merge patch?

In a merge patch, an object member set to null removes that member. Arrays are treated as indivisible values.

SQLite example and interpretation

Remove a retired threshold and replace candidates [1,2] with [7]. Choose an explicit setter if the key must remain present with a null value.

SELECT json_patch('{"limit":3,"ids":[1,2]}','{"limit":null,"ids":[7]}');

Result [["{\"ids\":[7]}"]]

中文

合并 JSON 配置时,补丁里的 null 有什么作用?

json_patch 应用合并补丁时,对象成员值为 null 表示移除该成员;数组作为整体处理。

SQLite 示例与适用条件

删除旧阈值并将候选列表 [1,2] 改为 [7]。如果业务需要保留一个值为 null 的键,应使用能显式赋值的操作。

SELECT json_patch('{"limit":3,"ids":[1,2]}','{"limit":null,"ids":[7]}');

结果 [["{\"ids\":[7]}"]]

References / 参考来源

Keep reading / 继续阅读