package org.magicdroid.test.server;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import org.jsonXX.JSONArray;
import org.jsonXX.JSONExceptionXX;
import org.jsonXX.JSONObjectXX;
import org.jsonXX.JSONWriter;
import org.magicdroid.commons.Structures;
import com.google.appengine.repackaged.org.json.CDL;
public class TestJSON extends TestCase {
public static class A {
public String vorname = "lallak";
public String getName() { return "cyz"; }
public void setName(String name) {}
}
public static class B {
private String mamma;
public String getMamma() { return this.mamma; }
public void setMamma(String mamma) { this.mamma = mamma; }
}
public Map<String, String> map = new Structures.MapCreator<String, String>(new HashMap<String, String>())
.add("ciao", "mamma")
.add("ecco", "qua")
.done();
// public void test1() throws JSONException {
// JSONArray array = new JSONArray();
//// JSONObject jsonA = new JSONObject();
// array.add(A.class);
// array.add(new A());
//// JSONObject jsonB = new JSONObject();
// array.add(B.class);
// array.add(new B());
// array.add(map);
//// json.put("blub", );
// System.out.println(array.toString());
// }
public void test2() throws Exception {
// JSONArray result = new JSONArray();
// JSONArray class1 = new JSONArray();
// class1.add(A.class);
// class1.add(new A());
// result.add(class1);
// String p = result.toString();
JSONArray first = new JSONArray();
JSONArray second = new JSONArray();
second.put(new JSONObjectXX(new A()));
first.put(second);
JSONObjectXX result = new JSONObjectXX();
result.put("params", first);
result.put("service","service.class");
result.put("method", "metodo");
// String o = new JSONObject()
// CDL.
System.out.println(result);
// JSONSerializer.toJava(new jsono)
}
}
|