Package javax.json.stream

Examples of javax.json.stream.JsonGenerator.writeStartObject()


  }

  public StringWriter generatePurchaseOrder() throws IOException {
    StringWriter writer = new StringWriter();
    JsonGenerator generator = Json.createGenerator(writer);
    generator.writeStartObject()
            .write("id", "1234")
            .write("date", "05/06/2013")
            .writeStartObject("customer")
            .write("first_name", "James")
            .write("last_name", "Rorrison")
View Full Code Here


    }

    @Override
    public void writeTo(Movie t, Class<?> type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap<String, Object> mm, OutputStream out) throws IOException, WebApplicationException {
        JsonGenerator gen = Json.createGenerator(out);
        gen.writeStartObject()
                .write("id", t.getId())
                .write("name", t.getName())
                .write("actors", t.getActors())
                .writeEnd();
        gen.flush();
View Full Code Here

                Annotation[] antns,
                MediaType mt,
                MultivaluedMap<String, Object> mm,
                OutputStream out) throws IOException, WebApplicationException {
        JsonGenerator gen = Json.createGenerator(out);
        gen.writeStartObject()
                .write("name", t.getName())
                .write("age", t.getAge())
                .writeEnd();
        gen.flush();
    }
View Full Code Here

//            JsonGenerator gen = factory.createGenerator(System.out);

            out.println("Creating an empty object ...<br>");
            JsonGenerator gen = factory.createGenerator(out);
//            JsonGenerator gen = Json.createGenerator(out);
            gen.writeStartObject().writeEnd();
            gen.flush();
            out.println("<br>...done<br>");

            out.println("<br>Creating a simple object ...<br>");
            gen = factory.createGenerator(out);
View Full Code Here

            gen.flush();
            out.println("<br>...done<br>");

            out.println("<br>Creating a simple object ...<br>");
            gen = factory.createGenerator(out);
            gen
                    .writeStartObject()
                    .write("apple", "red")
                    .write("banana", "yellow")
                    .writeEnd();
            gen.flush();
View Full Code Here

            gen.flush();
            out.println("<br>...done<br>");

            out.println("<br>Creating a nested structure ...<br>");
            gen = factory.createGenerator(out);
            gen
                    .writeStartObject()
                    .write("title", "The Matrix")
                    .write("year", 1999)
                    .writeStartArray("cast")
                    .write("Keanu Reaves")
View Full Code Here

    }

    @Override
    public void writeTo(Movie t, Class<?> type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap<String, Object> mm, OutputStream out) throws IOException, WebApplicationException {
        JsonGenerator gen = Json.createGenerator(out);
        gen.writeStartObject()
                .write("id", t.getId())
                .write("name", t.getName())
                .write("actors", t.getActors())
                .writeEnd();
        gen.flush();
View Full Code Here

                Annotation[] antns,
                MediaType mt,
                MultivaluedMap<String, Object> mm,
                OutputStream out) throws IOException, WebApplicationException {
        JsonGenerator gen = Json.createGenerator(out);
        gen.writeStartObject()
                .write("name", t.getName())
                .write("age", t.getAge())
                .writeEnd();
        gen.flush();
    }
View Full Code Here

    @Test
    public void testEmptyObject() throws JSONException {
        JsonGeneratorFactory factory = Json.createGeneratorFactory(null);
        StringWriter w = new StringWriter();
        JsonGenerator gen = factory.createGenerator(w);
        gen.writeStartObject().writeEnd();
        gen.flush();

        JSONAssert.assertEquals("{}", w.toString(), JSONCompareMode.STRICT);
    }
View Full Code Here

    public void testSimpleObject() throws JSONException {
        JsonGeneratorFactory factory = Json.createGeneratorFactory(null);
        StringWriter w = new StringWriter();
        JsonGenerator gen = factory.createGenerator(w);

        gen
                .writeStartObject()
                .write("apple", "red")
                .write("banana", "yellow")
                .writeEnd();
        gen.flush();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.