Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonFactory


        }
    }

    public static void write(JsonParser parser, OutputStream out) {
        try {
            JsonFactory jsonFactory = getJsonFactory();
            JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
            JsonNode node = parser.readValueAs(JsonNode.class);
            generator.writeTree(node);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
View Full Code Here


            LOG.debug("fields : {}", schema.getFieldNames());
        } catch (HCatException e) {
            throw new SerDeException(e);
        }

        jsonFactory = new JsonFactory();
    }
View Full Code Here

    private JsonGenerator jsonGenerator;
    private int depth;
    private BufferingInputOutputStream buffers;

    public JsonRootEatingInputStreamFilter(InputStream inputStream) throws IOException {
        JsonFactory jsonFactory = new JsonFactory();
        this.jsonParser = jsonFactory.createJsonParser(inputStream);
        this.buffers = new BufferingInputOutputStream();
        this.jsonGenerator = jsonFactory.createJsonGenerator(this.buffers, JsonEncoding.UTF8);
        this.depth = 0;
    }
View Full Code Here

        try {
            if ((rootName == null || "".equals(rootName)) && (configuration.isRootUnwrapping())) {
                rootName = "rootElement";
            }
           
            final JsonParser rawParser = new JsonFactory().createJsonParser(reader);
            final JsonParser nonListParser = configuration.isRootUnwrapping() ? JacksonRootAddingParser.createRootAddingParser
                    (rawParser, rootName) : rawParser;

            XmlEventProvider eventStack = null;
            switch (configuration.getNotation()) {
View Full Code Here

        super(testName);
    }

    public void testWrapppingNull() throws Exception {
        StringWriter sw = new StringWriter();
        JsonGenerator g = (new JsonFactory()).createJsonGenerator(sw);
        JsonGenerator awg = JacksonArrayWrapperGenerator.createArrayWrapperGenerator(g);
        awg.writeNull();
        awg.close();
        assertEquals("[]",sw.toString());
    }
View Full Code Here

        assertEquals("[]",sw.toString());
    }

    public void testWrapppingDoubleNull() throws Exception {
        StringWriter sw = new StringWriter();
        JsonGenerator g = (new JsonFactory()).createJsonGenerator(sw);
        JsonGenerator awg = JacksonArrayWrapperGenerator.createArrayWrapperGenerator(g);
        awg.writeNull();
        awg.writeNull();
        awg.close();
        assertEquals("[null,null]",sw.toString());
View Full Code Here

        assertEquals("[null,null]",sw.toString());
    }

    public void testWrapppingString() throws Exception {
        StringWriter sw = new StringWriter();
        JsonGenerator g = (new JsonFactory()).createJsonGenerator(sw);
        JsonGenerator awg = JacksonArrayWrapperGenerator.createArrayWrapperGenerator(g);
        awg.writeString("string");
        awg.close();
        assertEquals("[\"string\"]",sw.toString());
    }
View Full Code Here

        assertEquals("[\"string\"]",sw.toString());
    }

    public void testWrapppingNumberAndString() throws Exception {
        StringWriter sw = new StringWriter();
        JsonGenerator g = (new JsonFactory()).createJsonGenerator(sw);
        JsonGenerator awg = JacksonArrayWrapperGenerator.createArrayWrapperGenerator(g);
        awg.writeNumber(2);
        awg.writeString("string");
        awg.close();
        assertEquals("[2,\"string\"]",sw.toString());
View Full Code Here

            jaxbContext = ((JSONJAXBContext) jaxbContext).getOriginalJaxbContext();
        }

        switch (config.getNotation()) {
            case NATURAL:
                final JsonGenerator rawGenerator = new JsonFactory().createJsonGenerator(writer);
                if (config.isHumanReadableFormatting()) {
                    rawGenerator.useDefaultPrettyPrinter();
                }
                final JsonGenerator bodyGenerator = writingList ? JacksonArrayWrapperGenerator.createArrayWrapperGenerator(rawGenerator, config.isRootUnwrapping() ? 0 : 1) : rawGenerator;
                if (config.isRootUnwrapping()) {
View Full Code Here


    public void testMultipleCharactersWithinSimpleTagEvent() throws Exception {
        Map<String, Object> props = new HashMap<String, Object>();

        JsonFactory factory = new JsonFactory();
        Writer osWriter = new OutputStreamWriter(System.out);
        JsonGenerator g;

        g = factory.createJsonGenerator(osWriter);
        final Stax2JacksonWriter s2jWriter = new Stax2JacksonWriter(g, null, null);

        try {
            s2jWriter.writeStartDocument();
            s2jWriter.writeStartElement("simpleTag");
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.JsonFactory

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.