2、例子 json如下,我们需要拿到所有的重量
{"key1":{"key2":[{"weight":10},{"weight":15}]}}
将json存在字段snapshot中 snapshot::json->>'key1‘,是将snapshot文本看作json取出key1值 json_array_elements是查询一个json数组
--weight
SELECT json_array_elements(t2.key2Value::json)->'weight' weight from (
--key2Value :::[{"weight":10},{"weight":15}]
SELECT t1.key1Value ::json->>'key2' key2Value from (
--key1Value :::{"key2":[{"weight":10},{"weight":15}]}
SELECT snapshot::json->>'key1' key1Value from task_done_info where id ='74960048' limit 1
)t1
)t2

|