日期:2014-05-16 浏览次数:20450 次
JSON(JavaScript Object Notation): 是一种轻量级的数据交换格式
一、JSON建构有两种结构:对象和数组
(1)一个对象以“{”(左括号)开始,“}”(右括号)结束。
说了这些基本了解json的数据结构了...
补充:在线Json校验格式化工具:http://www.bejson.com/go.php?u=http://www.bejson.com/index.php
三、老样子上次demo
这时我的工程结构图:上面引用到的外部库大家网上搜索下载~

configdata.json:
[
    true,
    false,
    true
]Address类:
/**   
 * @Title: 创建Address实体类的POJO
 * @Description: TODO(用一句话描述该文件做什么)
 * @author Potter   
 * @date 2013-2-18 上午10:16:03
 * @version V1.0   
 */
public class Address {
	private String street;//街道
	private String city;//城市
	private int zip;//邮编
	private String tel;//第一个电话号码
	private String telTwo;//第二个电话号码
	public Address() {
	}
	public Address(String street, String city, int zip, String tel, String telTwo){
		this.street = street;
		this.city = city;
		this.zip = zip;
		this.tel = tel;
		this.telTwo = telTwo;
	}
	
	public String getStreet() {
		return street;
	}
	public void setStreet(String street) {
		this.street = street;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public int getZip() {
		return zip;
	}
	public void setZip(int zip) {
		this.zip = zip;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getTelTwo() {
		return telTwo;
	}
	public void setTelTwo(String telTwo) {
		this.telTwo = telTwo;
	}
}
JsonTest类:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONArray;
import net.sf.json.JSONFunction;
import net.sf.json.JSONObject;
public class JsonTest {
	public static void main(String args[]) {
		//javaArray和json互相转换
		javaArrayAndJsonInterChange();
		System.out.println("-------------------------------------");
		//javaList和json互相转换
		javaListAndJso