Java examples for JSON:JSON Creation
Building a JSON Object
import javax.json.Json; import javax.json.JsonBuilderFactory; import javax.json.JsonObject; public class Main { public static void main(String[] args) { JsonBuilderFactory factory = Json.createBuilderFactory(null); JsonObject obj = factory.createObjectBuilder() .add("title", "Java ") .add("author", "Ana Bates") .add("projectCoordinator", "Edith") .add("editor", "Lady Mary") .build(); } }