stringtree json

[size=medium]stringtree json is a small, neat and robust Java implementation of a reader, writer, and validator for the JSON (JavaScript Object Notation) data format. The reader and writer are one class each, with no dependencies at all.

stringtree json 有三个关键类
JSONWriter(JSONValidatingWriter)
JSONReader(JSONValidatingReader)
JSONValidator

[b]1.由json字符串得到Object, 使用JSONReader[/b]
JSON数组: [true, 123, "lolo"] 返回Collection,具体为ArrayList
JSON对象: {"name":"lulu", "age":123} 返回Map, 具体为HashMap
JSON数字: 123,12.3,返回对应java的数字类Number,Long,BigInteger,Double or BigDecimal
JSON字符串: "name" ,返回java的String对象
JSON true or false: true, false 返回java Boolean对象
JSON null: null 返回java null

[b]2.由java Object 得到 json字符串, 使用JSONWriter[/b]
1). If the Java object is null, generate a JSON null.
2). If the Java object is a Boolean, generate a JSON true or false.
3). If the Java object is a Number (such as an Integer, Double, etc), generate a JSON "number".
4). If the Java object is a String or a single character, generate a JSON "string"
5). If the Java object is a Map, generate a JSON "object" with the Map entries as elements.
6). If the Java object is an array, an iterator, or an iterable collection, generate a JSON "array"
7). Otherwise, treat the supplied object as a JavaBean, and generate a JSON "object" with the bean properties as elements.


[/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值