2

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!!

Yurets
  • 3,999
  • 17
  • 54
  • 74
justicepenny
  • 2,004
  • 2
  • 24
  • 48
  • Do you need to deserialize the entire file? If not, and are looking for something very specific, you could try to read it as a normal file – JRL Sep 28 '11 at 15:48
  • possible duplicate of [Parsing huge JSON object in Android?](http://stackoverflow.com/questions/5553101/parsing-huge-json-object-in-android) – Matt Ball Sep 28 '11 at 15:55

2 Answers2

1

Try using a streaming API:

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

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

jazz
  • 1,216
  • 7
  • 7