Flatten nested JSON using jq

前端 未结 4 408
独厮守ぢ
独厮守ぢ 2021-02-04 09:58

I\'d like to flatten a nested json object, e.g. {\"a\":{\"b\":1}} to {\"a.b\":1} in order to digest it in solr.

I have 11 TB of json files whi

4条回答
  •  无人共我
    2021-02-04 10:54

    Here is a solution that uses tostream, select, join, reduce and setpath

      reduce ( tostream | select(length==2) | .[0] |= [join(".")] ) as [$p,$v] (
         {}
         ; setpath($p; $v)
      )
    

提交回复
热议问题