Package com.sun.jersey.json.impl.writer

Examples of com.sun.jersey.json.impl.writer.Stax2JacksonWriter


                if (config.isHumanReadableFormatting()) {
                    rawGenerator.useDefaultPrettyPrinter();
                }
                final JsonGenerator bodyGenerator = writingList ? JacksonArrayWrapperGenerator.createArrayWrapperGenerator(rawGenerator, config.isRootUnwrapping() ? 0 : 1) : rawGenerator;
                if (config.isRootUnwrapping()) {
                    return new Stax2JacksonWriter(JacksonRootStrippingGenerator.createRootStrippingGenerator(bodyGenerator, writingList ? 2 : 1), config, expectedType, jaxbContext);
                } else {
                    return new Stax2JacksonWriter(bodyGenerator, config, expectedType, jaxbContext);
                    }
            case MAPPED:
                return JsonXmlStreamWriter.createWriter(writer, config, JSONHelper.getRootElementName((Class<Object>) expectedType));
            case BADGERFISH:
                return new BadgerFishXMLStreamWriter(writer);
View Full Code Here


        StringWriter resultWriter = new StringWriter();

        JsonFactory jsonFactory = new JsonFactory();
        JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(resultWriter);

        final Stax2JacksonWriter writer = configuration != null
                ? new Stax2JacksonWriter(jsonGenerator, configuration, clazz, jaxbContext) : new Stax2JacksonWriter(jsonGenerator, clazz, jaxbContext);

        marshaller.marshal(jaxbBean, writer);
        System.out.println(String.format("Marshalled: %s", resultWriter.toString()));
        assertEquals("MISMATCH:\n" + expectedJsonExpr + "\n" + resultWriter.toString() + "\n",
                normalizeJsonString(expectedJsonExpr), normalizeJsonString(resultWriter.toString()));
View Full Code Here

        JsonGenerator g;

        g = factory.createJsonGenerator(sWriter);

        Marshaller marshaller = ctx.createMarshaller();
        marshaller.marshal(bean, new Stax2JacksonWriter(g, clazz, ctx));

        g.flush();

        String jsonExpression = sWriter.toString();
        System.out.println(jsonExpression);
View Full Code Here

        final JsonFactory factory = new JsonFactory();
        final Writer sWriter = new StringWriter();
        final JsonGenerator jsonGenerator = factory.createJsonGenerator(sWriter);

        final Marshaller marshaller = context.createMarshaller();
        marshaller.marshal(testInstance, new Stax2JacksonWriter(jsonGenerator, clazz, context));

        jsonGenerator.flush();
        return sWriter.toString();
    }
View Full Code Here

        g = factory.createJsonGenerator(sWriter);

        Marshaller marshaller = ctx.createMarshaller();
//        marshaller.marshal(bean, System.out);
        marshaller.marshal(bean, new Stax2JacksonWriter(g));

        g.flush();

        String jsonExpression = sWriter.toString();
        System.out.println(jsonExpression);
View Full Code Here

TOP

Related Classes of com.sun.jersey.json.impl.writer.Stax2JacksonWriter

Copyright © 2018 www.massapicom. 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.