javax.json.JsonObject 인터페이스는 변경할 수 없는 JSON 개체 값을 나타낼 수 있으며 수정할 수 없는 지도 JSON 개체 이름/값 보기 매핑. JsonObject 정적 을 사용하여 입력 소스에서 인스턴스를 생성할 수 있습니다. readObject() 메서드 javax.json. JsonReader 클래스이며 정적 을 사용하여 만들 수도 있습니다. 메소드 createObjectBuilder() javax.json. 제이슨 수업.
구문
public static JsonObjectBuilder createObjectBuilder()
예시
import java.io.*;
import javax.json.*;
public class JsonObjectTest {
public static void main(String[] args) throws Exception {
JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add("Name", "Adithya");
builder.add("Designation", "Python Developer");
builder.add("Company", "TutorialsPoint");
builder.add("Location", "Hyderabad");
JsonObject data = builder.build();
StringWriter sw = new StringWriter();
JsonWriter jw = Json.createWriter(sw);
jw.writeObject(data);
jw.close();
System.out.println(sw.toString());
}
} 출력
{"Name":"Adithya","Designation":"Python Developer","Company":"TutorialsPoint","Location":"Hyderabad"}