是否有用于JSON的流API? [英] Is there a streaming API for JSON?

查看:105
本文介绍了是否有用于JSON的流API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DOM是解析JSON的唯一方法吗?

Is DOM the only way to parse JSON?

推荐答案

某些JSON解析器确实提供了增量(流")解析器;对于Java,至少在json.org页的以下解析器中提供了这样的接口:

Some JSON parsers do offer incremental ("streaming") parser; for Java, at least following parsers from json.org page offer such an interface:

  • Jackson (pull interface)
  • Json-simple (SAX-style push interface)

(除了另一个答案所引用的Software Monkey的解析器之外)

(in addition to Software Monkey's parser referred to by another answer)

实际上,这么多JSON解析器不提供此简单的低级接口是很奇怪的-毕竟,它们已经需要实现低级解析,所以为什么不公开它.

Actually, it is kind of odd that so many JSON parsers do NOT offer this simple low-level interface -- after all, they already need to implement low-level parsing, so why not expose it.

编辑(2011年6月):Gson也有自己的流API (带有gson 1.6)

EDIT (June 2011): Gson too has its own streaming API (with gson 1.6)

这篇关于是否有用于JSON的流API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆