JSON.simple
<p>JSON.simple是一个简单的Java类库,用于解析和生成JSON文本。不依赖于其它类库,性能高。</p> <ul> <li>Full compliance with <a href="/misc/goto?guid=4959499401825879130" rel="nofollow">JSON specification</a> (RFC4627) and reliable (see <a href="/misc/goto?guid=4959499401915947562">compliance testing</a>) </li> </ul> <ul> <li>Provides multiple functionalities such as encode, decode/parse and escape JSON text while keeping the library lightweight </li> </ul> <ul> <li>Flexible, simple and easy to use by reusing Map and List interfaces </li> </ul> <ul> <li>Supports streaming output of JSON text </li> </ul> <ul> <li>Stoppable SAX-like interface for streaming input of JSON text (learn <a href="/misc/goto?guid=4959499401986005624" rel="nofollow">more</a>) </li> </ul> <ul> <li>Heap based parser </li> </ul> <ul> <li>High performance (see <a href="/misc/goto?guid=4959499402072930935">performance testing</a>) </li> </ul> <ul> <li>No dependency on external libraries </li> </ul> <ul> <li>Both of the source code and the binary are JDK1.2 compatible </li> </ul> <p>示例代码:</p> <pre class="brush:java; toolbar: true; auto-links: false;">System.out.println("=======decode======="); String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]"; Object obj=JSONValue.parse(s); JSONArray array=(JSONArray)obj; System.out.println("======the 2nd element of array======"); System.out.println(array.get(1)); System.out.println(); JSONObject obj2=(JSONObject)array.get(1); System.out.println("======field \"1\"=========="); System.out.println(obj2.get("1")); s="{}"; obj=JSONValue.parse(s); System.out.println(obj); s="[5,]"; obj=JSONValue.parse(s); System.out.println(obj); s="[5,,2]"; obj=JSONValue.parse(s); System.out.println(obj);</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324198061530" target="_blank">http://www.open-open.com/lib/view/home/1324198061530</a></p> <p></p>
本文由用户 openkk 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!