我有一个由科学仪器创建的层次较深的
JSON对象,因此该文件有点大(1.3MB),并且人们不容易阅读.我想获得JSON对象的密钥列表,直到一定深度.例如,给出这样的输入对象
{ "acquisition_parameters": { "laser": { "wavelength": { "value": 632,"units": "nm" } },"date": "02/03/2525","camera": {} },"software": { "repo": "github.com/username/repo","commit": "a7642f","branch": "develop" },"data": [{},{},{}] }
我想要这样的输出.
{ "acquisition_parameters": [ "laser","date","camera" ],"software": [ "repo","commit","branch" ] }
这主要是为了能够枚举JSON对象中的内容.处理JSON对象后,仪器开始分歧:例如,有些可能有一个字段,如.frame.cross_section.stats.fwhm,而其他可能有.sample.species,所以能方便查询命令行上的JSON对象.