Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonFactory.createJsonGenerator()


    Schema avroSchema = Schema.parse(schema);
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory factory = new JsonFactory();
    StringWriter writer = new StringWriter();
    JsonGenerator jgen = factory.createJsonGenerator(writer);
    jgen.useDefaultPrettyPrinter();

    @SuppressWarnings("checked")
    HashMap<String,Object> schemaMap = new ObjectMapper().readValue(schema, HashMap.class);
View Full Code Here


                       ". Generated at " + df.format(new Date(System.currentTimeMillis())));

      ObjectMapper mapper = new ObjectMapper();
      JsonFactory factory = new JsonFactory();
      StringWriter writer = new StringWriter();
      JsonGenerator jgen = factory.createJsonGenerator(writer);
      jgen.useDefaultPrettyPrinter();
      mapper.writeValue(jgen, field);
      return writer.getBuffer().toString();
    }
    catch(Exception ex)
View Full Code Here

         throws JsonGenerationException, JsonMappingException, IOException
  {
    JsonFactory jsonFactory = new JsonFactory(new ObjectMapper());

    StringWriter out = new StringWriter(1000);
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(out);
    if (pretty) jsonGenerator.useDefaultPrettyPrinter();
    jsonGenerator.writeObject(bean);
    out.flush();

    return out.toString();
View Full Code Here

    tableInfo.add(columnInfo5);
   
    ObjectMapper objectMapper = new ObjectMapper();     
    JsonFactory jsonFactory = new JsonFactory()
    StringWriter writer = new StringWriter();
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
    objectMapper.writeValue(jsonGenerator, tableInfo);
    String jsonString = writer.toString();
    when(context.getConfiguration().get(HIHOConf.COLUMN_INFO)).thenReturn(jsonString);
   
    mapper.setup(context);
View Full Code Here

  public static String getJsonStringOfColumnInfo(ArrayList<ColumnInfo> columnInfo) throws IOException {
    ObjectMapper mapper = new ObjectMapper();     
    JsonFactory jsonFactory = new JsonFactory()
    StringWriter writer = new StringWriter();
    JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(writer);
    mapper.writeValue(jsonGenerator, columnInfo);
    String jsonString = writer.toString();
    return jsonString;
  }
View Full Code Here

      ObjectMapper jmapper = new ObjectMapper();
      jmapper.configure(
          SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
      JsonFactory jfactory = jmapper.getJsonFactory();
      FileSystem jobFS = jobTraceFilename.getFileSystem(getConf());
      jobTraceGen = jfactory.createJsonGenerator(
          jobFS.create(jobTraceFilename), JsonEncoding.UTF8);
      if (prettyprintTrace) {
        jobTraceGen.useDefaultPrettyPrinter();
      }
View Full Code Here

        ObjectMapper tmapper = new ObjectMapper();
        tmapper.configure(
            SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
        JsonFactory tfactory = tmapper.getJsonFactory();
        FileSystem topoFS = topologyFilename.getFileSystem(getConf());
        topologyGen = tfactory.createJsonGenerator(
            topoFS.create(topologyFilename), JsonEncoding.UTF8);
        topologyGen.useDefaultPrettyPrinter();
      }
    }
View Full Code Here

   * @throws IOException
   */
  public static void dumpConfiguration(Configuration config,
      Writer out) throws IOException {
    JsonFactory dumpFactory = new JsonFactory();
    JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
    dumpGenerator.writeStartObject();
    dumpGenerator.writeFieldName("properties");
    dumpGenerator.writeStartArray();
    dumpGenerator.flush();
    synchronized (config) {
View Full Code Here

        File tmpFile = new File(manifestFile.getPath().replace(EXTENSION, "-tmp.json"));

        JsonFactory f = new JsonFactory();
        try
        {
            JsonGenerator g = f.createJsonGenerator(tmpFile, JsonEncoding.UTF8);
            g.useDefaultPrettyPrinter();
            g.writeStartObject();
            g.writeArrayFieldStart("generations");
            for (int level = 0; level < generations.length; level++)
            {
View Full Code Here

   
    public void jacksonTest() throws Exception
    {
        JsonFactory factory = new JsonFactory();
        StringWriter writer = new StringWriter();
        JsonGenerator generator = factory.createJsonGenerator(writer);
        generator.writeStartObject();
        generator.writeFieldName("bool");
        generator.writeBoolean(true);
        generator.writeFieldName("firstName");
        generator.writeString("john");
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.