开发者

500KB json file parsed in Android environment

开发者 https://www.devze.com 2023-04-08 03:40 出处:网络
I need to find a faster solution to parse a json file with 500KB. the structure is something like { \"response\": {

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

精彩评论

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

关注公众号