Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonFactory


    public Tests(int bufferSize, int depth, String input)
      throws IOException {
 
      this.depth = depth;
      byte[] in = input.getBytes("UTF-8");
      JsonFactory f = new JsonFactory();
      JsonParser p = f.createJsonParser(
          new ByteArrayInputStream(input.getBytes("UTF-8")));
     
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      Encoder cos = new BlockingBinaryEncoder(os, bufferSize);
      serialize(cos, p, os);
      cos.flush();
     
      byte[] bb = os.toByteArray();
      // dump(bb);
      this.input = DecoderFactory.defaultFactory().createBinaryDecoder(bb, null);
      this.parser =  f.createJsonParser(new ByteArrayInputStream(in));
    }
View Full Code Here


  private final JsonNode data;
 
  public TestResolvingGrammarGenerator(String jsonSchema, String jsonData)
    throws IOException {
    this.schema = Schema.parse(jsonSchema);
    JsonFactory factory = new JsonFactory();
    ObjectMapper mapper = new ObjectMapper(factory);

    this.data = mapper.readTree(new StringReader(jsonData));
  }
View Full Code Here

      return schema;
    }

    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

      SimpleDateFormat df = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a zzz");
      field.put("doc", "Auto-generated Avro schema for " + topRecordDatabaseName +
                       ". 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

   * @return        the JSON string
   */
  public static <T>String toJsonString(T bean, boolean pretty)
         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(columnInfo3);
    //tableInfo.add(columnInfo4);
    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

                    @Override
                    public void writeTo(BufferedWriter out) throws IOException {

                        while(entriesIterator.hasNext()) {
                            final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);
                            Pair<ByteArray, Versioned<byte[]>> kvPair = entriesIterator.next();
                            byte[] keyBytes = kvPair.getFirst().get();
                            byte[] valueBytes = kvPair.getSecond().getValue();
                            VectorClock version = (VectorClock) kvPair.getSecond().getVersion();
View Full Code Here

                    @Override
                    public void writeTo(BufferedWriter out) throws IOException {

                        while(keyIterator.hasNext()) {
                            final JsonGenerator generator = new JsonFactory(new ObjectMapper()).createJsonGenerator(out);

                            byte[] keyBytes = keyIterator.next().get();
                            Object keyObject = serializer.toObject((null == keysCompressionStrategy) ? keyBytes
                                                                                                    : keysCompressionStrategy.inflate(keyBytes));
View Full Code Here

            out.write(prefix + "_TEXT\n====================================\n");
            if(inputObject instanceof GenericRecord) {
                out.write(inputObject.toString());
            } else {
                new JsonFactory(new ObjectMapper()).createJsonGenerator(out)
                                                   .writeObject(inputObject);
            }
            out.write("\n====================================\n\n");
        } catch(SerializationException e) {}
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

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.