views:

49

answers:

1

I am trying to use gson to do my object mapping on the android emulator.

It has been ridiculously slow when processing json data around 208 kb. I do not have any hierarchies in my json.

After the object mapping is done, i can see it that gson created around 500 records.

It is taking it over 3 minutes on the android emulator to map the input json.

I have annotated my entity which comprises of strings and couple of floats.

An I missing something?

Any ideas, best practices would greatly help.

Are there any ways of quickly object mapping the json data?

        URL myURL = new URL(url);
        /* Open a connection to that URL. */
        URLConnection ucon = myURL.openConnection();
        /*
         * Define InputStreams to read from the URLConnection.
         */
        InputStream is = ucon.getInputStream();
        InputStreamReader reader = new InputStreamReader(is);
        long tickCount = System.currentTimeMillis();
        Policy[] policies = new Gson().fromJson(reader, Policy[].class);
        long endCount = System.currentTimeMillis() - tickCount;
        Log.d("Time to pull policies in milliseconds", "" + endCount);
+1  A: 

I've seen questions like this come up before, and the general consensus is that Jackson is much faster than Gson. See the following links for more information:

Here is one which specifically discusses Android: http://ubikapps.net/?p=525

Matt Solnit