How do you list full paths to integer leaves in a nested configuration?
json_tree recursively walks a document. fullkey names the node location and type can select particular leaves.
SQLite example and interpretation
A step count and two layer widths yield three paths. Array indices can move when the configuration is reordered, so avoid treating paths as permanent IDs.
SELECT fullkey,atom FROM json_tree('{"steps":5,"width":[8,4]}') WHERE type='integer' ORDER BY fullkey;Result [["$.steps", 5], ["$.width[0]", 8], ["$.width[1]", 4]]
中文
如何列出嵌套配置里每个整数值的完整路径?
json_tree 递归遍历 JSON;fullkey 描述当前节点的位置,type 可筛选叶子类型。
SQLite 示例与适用条件
配置同时含学习步数与两级层宽,按整数类型提取会得到三个路径。数组下标会随重排变化,不宜当永久标识。
SELECT fullkey,atom FROM json_tree('{"steps":5,"width":[8,4]}') WHERE type='integer' ORDER BY fullkey;结果 [["$.steps", 5], ["$.width[0]", 8], ["$.width[1]", 4]]