stringtree json

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

1.由json字符串得到Object, 使用JSONReader
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

2.由java Object 得到 json字符串, 使用JSONWriter
   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.


你可能感兴趣的:(JavaScript,java,json,bean)