1   /*
2    * Created on 2005/08/25
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package test.tuigwaa;
8   
9   import java.util.ArrayList;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  
14  import org.json.JSONObject;
15  
16  import junit.framework.TestCase;
17  
18  /***
19   * @author nishioka
20   *
21   * TODO To change the template for this generated type comment go to
22   * Window - Preferences - Java - Code Style - Code Templates
23   */
24  public class JSONTest extends TestCase {
25  
26  	public void testEscape(){
27  		String test = "hoge=\"test\"";
28  		System.out.println(test);
29  		String escape = JSONObject.quote(test);
30  		
31  		System.out.println(escape);
32  		
33  		assertEquals("\"hoge=//\"test//\"\"", escape);
34  	}
35  	
36  	public void testCreateJSON(){
37  		Map map = new HashMap();
38  		List list = new ArrayList();
39  		map.put("hoge1", new Integer(2));
40  		
41  		list.add("hoge1");
42  		list.add("hoge2");
43  		list.add("hoge3");
44  		
45  				
46  		map.put("hoge2", list);
47  
48  		JSONObject obj = new JSONObject(map);
49  		System.out.println(obj.toString());
50  	}	
51  	
52  }