forked from eugenejade/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject01_B.java
More file actions
29 lines (21 loc) · 777 Bytes
/
Project01_B.java
File metadata and controls
29 lines (21 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import org.json.*;
public class Project01_B {
public static void main(String[] args) {
// JSON-Java(org.json)
JSONArray students=new JSONArray();
JSONObject student=new JSONObject();
student.put("name", "홍길동");
student.put("phone", "010-1111-1111");
student.put("address", "서울");
System.out.println(student); // {"address":"서울","phone":"010-1111-1111","name":"홍길동"}
students.put(student);
student=new JSONObject();
student.put("name", "나길동");
student.put("phone", "010-2222-2222");
student.put("address", "광주");
students.put(student);
JSONObject object=new JSONObject();
object.put("students", students);
System.out.println(object.toString(2));
}
}