I have class like this:
public class Class1 {
private String result;
private String ip;
private ArrayList alarm;
}
Wh
I think the utilizing org.json.lib's JSONObject(Object) constructor is what you're looking for. It will construct a JSONObject from your Java Object based on its getters. You can then use JSONObject#toString to get the actual Json produced.
JSONObject jsonObject = new JSONObject(instanceOfClass1);
String myJson = jsonObject.toString();