在Android中解析巨大的JSON对象?

在Android中解析巨大的JSON对象?,第1张

概述如何解析Android中的巨大JSON文件?当我解析这样的文件时,我在日志上看到这样的东西:04-0515:55:46.490:DEBUG/dalvikvm(3847):GCfreed12159objects/557744bytesin142ms04-0515:55:46.490:INFO/global(3847):DefaultbuffersizeusedinBufferedReaderconstructo

如何解析Android中的巨大JsON文件?

当我解析这样的文件时,我在日志上看到这样的东西:

04-05 15:55:46.490: DEBUG/dalvikvm(3847): GC freed 12159 objects / 557744 bytes in 142ms04-05 15:55:46.490: INFO/global(3847): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.04-05 15:55:46.650: DEBUG/dalvikvm(3847): GC freed 56 objects / 100176 bytes in 115ms04-05 15:55:46.660: INFO/dalvikvm-heap(3847): Grow heap (frag case) to 4.207MB for 110626-byte allocation04-05 15:55:46.760: DEBUG/dalvikvm(3847): GC freed 0 objects / 0 bytes in 104ms04-05 15:55:46.890: DEBUG/dalvikvm(3847): GC freed 3 objects / 73856 bytes in 115ms04-05 15:55:47.050: DEBUG/dalvikvm(3847): GC freed 7 objects / 110872 bytes in 113ms04-05 15:55:47.050: INFO/dalvikvm-heap(3847): Grow heap (frag case) to 4.426MB for 248896-byte allocation04-05 15:55:47.150: DEBUG/dalvikvm(3847): GC freed 0 objects / 0 bytes in 104ms04-05 15:55:47.310: DEBUG/dalvikvm(3847): GC freed 8 objects / 166232 bytes in 106ms04-05 15:55:47.310: INFO/dalvikvm-heap(3847): Grow heap (frag case) to 4.624MB for 373340-byte allocation04-05 15:55:47.420: DEBUG/dalvikvm(3847): GC freed 0 objects / 0 bytes in 106ms04-05 15:55:47.580: DEBUG/dalvikvm(3847): GC freed 10 objects / 249288 bytes in 111ms04-05 15:55:47.590: INFO/dalvikvm-heap(3847): Grow heap (frag case) to 4.920MB for 560006-byte allocation04-05 15:55:47.690: DEBUG/dalvikvm(3847): GC freed 0 objects / 0 bytes in 98ms04-05 15:55:47.810: DEBUG/dalvikvm(3847): GC freed 12 objects / 373792 bytes in 88ms04-05 15:55:47.910: DEBUG/dalvikvm(3847): GC freed 4 objects / 560088 bytes in 87ms04-05 15:55:48.010: DEBUG/dalvikvm(3847): GC freed 5 objects / 128 bytes in 88ms04-05 15:55:48.010: INFO/dalvikvm-heap(3847): Grow heap (frag case) to 5.350MB for 461302-byte allocation04-05 15:55:48.130: DEBUG/dalvikvm(3847): GC freed 0 objects / 0 bytes in 120ms04-05 15:55:48.990: DEBUG/dalvikvm(3847): GC freed 10419 objects / 1383992 bytes in 109ms04-05 15:55:49.720: DEBUG/dalvikvm(3847): GC freed 8769 objects / 384360 bytes in 115ms04-05 15:55:50.550: DEBUG/dalvikvm(3847): GC freed 10472 objects / 454880 bytes in 129ms04-05 15:55:51.590: DEBUG/dalvikvm(3847): GC freed 12663 objects / 554440 bytes in 147ms

是否有Json文件的拉解析器?怎么处理这样的事情?

解决方法:

看看Jackson JsON解析器,它比AndroID更快,比GSON更快,并支持流式传输.

http://jackson.codehaus.org/

然而,我重申其他人的观点,即你的JsON是巨大的,这确实表明了非优化设计.例如如果连接不稳定并且几次失败,您可能会导致用户在移动数据计划上产生额外的数据成本.总是更好地在可能的情况下将其分解,因此失败不涉及再次请求整个批次.

总结

以上是内存溢出为你收集整理的在Android中解析巨大的JSON对象?全部内容,希望文章能够帮你解决在Android中解析巨大的JSON对象?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:http://outofmemory.cn/web/1115883.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存