简体   繁体   English

将 dict 的 dict 转换为 json

[英]convert a dict of dict to json

I am trying to convert a dict of dict to json in order to read it with java (jsonLib java).我正在尝试将 dict 的 dict 转换为 json 以便使用 java (jsonLib java) 读取它。 The problem here is that I have a big Json file (130 mb) and it seems that all the date is in only one line.这里的问题是我有一个很大的 Json 文件(130 mb),似乎所有的日期都在一行中。 so I have a java out of memory exception when I try to read the file ( I read it with BufferedReader from java.io)所以当我尝试读取文件时,我有一个来自 memory 异常的 java (我使用 java.io 的 BufferedReader 读取它)

here is the code for dumping the json file:这是转储 json 文件的代码:

    import json
    instance ={}
    instance['key1']= [a,b]
    instance['key2'] = dict of dict of dict
    instance['key3'] = dict
    instance['key4'] = dict of dict of dict 
    instance['key5'] = dict of dict

    json.dump(instance,outputFile)

So how can I organize the json file in order to parse it as simple as possible in java.那么如何组织 json 文件以便在 java 中尽可能简单地解析它。 Thanks for your help谢谢你的帮助

You could break up the JSON payload into multiple files, perhaps one for each dict.您可以将 JSON 有效负载分解为多个文件,可能每个 dict 一个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM