开发者

500KB json file parsed in Android environment

I need to find a faster solution to parse a json file with 500KB. the structure is something like

{
    "response": {
        "code": 0,
        "msg": "OK",
        "searchparameter": {
            "bikes": { … },
            "cars": { 
                 "a":{
                     values[{...}]
                  },
                 "b":{},
                 "c":{},
                 "d":{},
                  "e":{},
           ...

            }
        }
   开发者_高级运维}
}

I tried gson.fromJson(jsontxt, Response.class), but it causes me like more than 5 mins to parse.. Is there any solutions that is suitable for me? How can I do JSONReader by gson in this case? and would it be helpful? any helps would be appreciated. thanks a lot!!


Try using a streaming API:

  • For Gson, https://sites.google.com/site/gson/streaming
  • Or switch to Jackson: Parsing huge JSON object in Android?


you can use Gson itself but to make it useful try it in using Asyntask so you can tell the user to wait by showing progressDialog

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜