Json依存パッケージJSOnObject

1565 ワード

renren-wap-framework-logic
Json依存パッケージJSOnObject
jsonrpc-1.0.0.jar

import java.text.ParseException;

import org.json.JSONObject;


/**
 * $Id$
 * Copyright 2009-2010 Oak Pacific Interactive. All rights reserved.
 */

/**
 * 
 * @author <a href="mailto:[email protected]">  </a>
 * @createTime 2011-7-20  01:34:01
 */
public class Test {

	/**
	 * @param args
	 * @throws ParseException 
	 */
	public static void main(String[] args) throws ParseException {
		System.out.print("123");
		String str = "{name:'  1',url:'http://www.renren.com/testiphone1.html', displayOrder:1}," +
		"{name:'  2',url:'http://www.renren.com/testiphone2.html', displayOrder:2}," + 
		"{name:'  3',url:'http://www.renren.com/testiphone3.html', displayOrder:3}";
		System.out.println("sna"+ str);
		
		JSONObject jsonObject = new JSONObject(str);
        //    
        String name = jsonObject.getString("name");
        String url = jsonObject.getString("url");
        int displayOrder = jsonObject.getInt("displayOrder");
        //  model
        System.out.print(name+ " ");
        System.out.print(url + " ");
        System.out.print(displayOrder);
        
	}

}