All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.java.test.TestIndenter Maven / Gradle / Ivy

Go to download

Jackson is a high-performance JSON processor (parser, generator)

The newest version!
package test;

import java.io.*;

import org.codehaus.jackson.*;
import org.codehaus.jackson.map.*;

public class TestIndenter
{
    public static void main(String[] args)
        throws IOException
    {
        if (args.length != 1) {
            System.err.println("Usage: java ... TestIndenter [file]");
            System.exit(1);
        }
        JsonFactory f = new JsonFactory();
        JsonParser jp = f.createJsonParser(new File(args[0]));
        JsonNode jn = new JsonTypeMapper().read(jp);

        StringWriter sw = new StringWriter(200);
        JsonGenerator jg = f.createJsonGenerator(sw);

        jg.useDefaultPrettyPrinter();

        jn.writeTo(jg);
        jg.close();

        System.out.println("DOC-><");
        System.out.println(sw.toString());
        System.out.println(">");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy