我有一个带有数组的嵌套Json文件。 我想把它放平,这样就不会有嵌套的json了。在
例如:
Json代码: https://jsonblob.com/4b255e51-7e9f-11e8-b89c-37203846213e
这个Json有子Json和包含Json的数组。在
来源是:
输出应为:
如果存在包含单个Json的数组,则可以忽略它们。但如果它们也有子json,则应按上述方式处理。从我的观点来看,基本上每个数组都像一个单独的Json文件。在
我知道压缩Json的方法如下:
from pandas.io.json import json_normalize
json_normalize(sample_object)
但这不适用于数组。在
你知道怎么做吗?在
编辑:
数组的处理方法如下: 资料来源:
输出:
{a6}
这意味着数组中的第一个Json保持不变{0}、{1}等。。。但是副JSON是扁平的。没有attributes_0_value
的列!基本上用一个Json把它转换成数组。无嵌套(除非有另一个数组)。在
尝试使用this:
我个人使用这个程序。在
<或JSON>从第一个文件加载到JSON>(从第一个文件加载)
使用来自pandas的嵌套的\u to_record()方法
输出:
相关问题 更多 >
编程相关推荐