build a jsonobject java with 3 differents object code example
Example 1: new jsonobject java
String message;
JSONObject json = new JSONObject();
json.put("name", "student");
JSONArray array = new JSONArray();
JSONObject item = new JSONObject();
item.put("information", "test");
item.put("id", 3);
item.put("name", "course1");
array.add(item);
json.put("course", array);
message = json.toString();
Example 2: JSONObject java
import org.json.simple.JSONObject;
class JsonEncodeDemo {
public static void main(String[] args) {
JSONObject obj = new JSONObject();
inputJSON.put("subscriberName", "subscriber");
inputJSON.put("msisdn","7055389495");
System.out.print(obj);
}
}