@@ -0,0 +1,1674 @@
+package de.asw.courses.web2016.demo.backend.jsonp;%0A%0Aimport java.io.StringReader;%0A%0Aimport javax.json.Json;%0Aimport javax.json.JsonObject;%0Aimport javax.json.JsonReader;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.core.MediaType;%0A%0A/**%0A * %3Cpre%3E%0A * %7B@code curl -v http://localhost:8080/asw2016-demo-webapp/resources/lifecycle%7D%0A * %3C/pre%3E%0A */%0A@Path(%22/jsonp%22)%0Apublic class JsonpExampleResource %7B%0A%0A%09@GET%0A%09@Path(%22/student%22)%0A%09@Produces(MediaType.APPLICATION_JSON)%0A%09public JsonObject getExampleStudent() %7B%0A%0A%09%09JsonObject student = Json.createObjectBuilder() //%0A%09%09%09%09.add(%22firstname%22, %22Harry%22) //%0A%09%09%09%09.add(%22lastname%22, %22Potter%22) //%0A%09%09%09%09.add(%22matriculationNo%22, %2212432343%22) //%0A%09%09%09%09.add(%22major%22, %22Information Management%22) //%0A%09%09%09%09.add(%22subjects%22,%0A%09%09%09%09%09%09Json.createArrayBuilder() //%0A%09%09%09%09%09%09%09%09.add(Json.createObjectBuilder().add(%22name%22, %22Math 101%22)) //%0A%09%09%09%09%09%09%09%09.add(Json.createObjectBuilder().add(%22name%22, %22Intro to Web Applications%22)) //%0A%09%09%09%09).build();%0A%0A%09%09System.out.println(%22Created json object%22);%0A%09%09System.out.println(student);%0A%0A%09%09return student;%0A%09%7D%0A%0A%09@GET%0A%09@Path(%22/studentFromString%22)%0A%09@Produces(MediaType.APPLICATION_JSON)%0A%09public JsonObject printJsonObjectString() throws Exception %7B%0A%0A%09%09StringReader reader = new StringReader( //%0A%09%09%09%09%22%7B%5C%22firstname%5C%22:%5C%22Harry%5C%22%22 //%0A%09%09%09%09%09%09+ %22,%5C%22lastname%5C%22:%5C%22Potter%5C%22%22 //%0A%09%09%09%09%09%09+ %22,%5C%22matriculationNo%5C%22:%5C%2212432343%5C%22%22 //%0A%09%09%09%09%09%09+ %22,%5C%22major%5C%22:%5C%22Information Management%5C%22%22 //%0A%09%09%09%09%09%09+ %22,%5C%22subjects%5C%22:%5B%7B%5C%22name%5C%22:%5C%22Math 101%5C%22%7D%22 //%0A%09%09%09%09%09%09+ %22,%7B%5C%22name%5C%22:%5C%22Intro to Web Applications%5C%22%7D%5D%7D%22 //%0A%09%09);%0A%0A%09%09JsonReader jsonReader = Json.createReader(reader);%0A%09%09JsonObject student = jsonReader.readObject();%0A%0A%09%09return student;%0A%09%7D%0A%7D%0A

Add JSONP example