Net.Sf.Json java Object to JsonObject
public class People{
private String name;
public void setName(String name){
this.name = name;
}
public String name{
return name;
}
public void setAge(int age){
this.age = age;
}
public int age{
return age;
}
}
import net.sf.Json..
public class test{
public static void main(String args[]){
People aPeople = new People();
aPeople.name = "name";
aPeople.age = 20
JsonObject jsonObj = JsonObject.fromObject(aPeople);
String jsonStr = jsonObj.toString();
}
}
注意点 、 People类的set get 方法要写