我正在尝试在Android模拟器上使用Gson进行对象映射。
当处理大约208 kb的JSON数据时,速度非常缓慢。我的JSON中没有层次结构。
对象映射完成后,我可以看到Gson创建了大约500条记录。
在Android模拟器上,将输入的JSON映射需要超过3分钟。
我的实体已经被注释,包括字符串和几个浮点数。
我错过了什么吗?
有任何想法、最佳实践都会极大地帮助。
是否有任何快速对象映射JSON数据的方法?
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);