Package org.codehaus.jackson

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


      cos.flush();
     
      byte[] bb = os.toByteArray();
      // dump(bb);
      this.input = new BinaryDecoder(new ByteArrayInputStream(bb));
      this.parser =  f.createJsonParser(new ByteArrayInputStream(in));
    }
   
    public void scan()
      throws JsonParseException, UnsupportedEncodingException, IOException {
      Stack<S> countStack = new Stack<S>();
View Full Code Here


    private Map<String, String> parseJSON(String jsonmessage){
        Map<String, String> parsed = new HashMap<String, String>();
        JsonFactory jf = new JsonFactory();
        try {
            JsonParser parser = jf.createJsonParser(jsonmessage);
            parser.nextToken(); //shift past the START_OBJECT that begins the JSON
            while (parser.nextToken() != JsonToken.END_OBJECT) {
                String fieldname = parser.getCurrentName();
                parser.nextToken(); // move to value, or START_OBJECT/START_ARRAY
                String value = parser.getText();
View Full Code Here

    Map<String, Map<String, String>> mapFields = Maps.newHashMap();
    byte[] rawPayload = null;

    try {
      JsonFactory f = new JsonFactory();
      JsonParser jp = f.createJsonParser(bais);

      jp.nextToken(); // will return JsonToken.START_OBJECT (verify?)
      while (jp.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = jp.getCurrentName();
        jp.nextToken(); // move to value, or START_OBJECT/START_ARRAY
View Full Code Here

    r.put(stringField.name(), "hello\nthere\"\tyou}");
    r.put(enumField.name(), new GenericData.EnumSymbol(enumField.schema(),"a"));
   
    String json = r.toString();
    JsonFactory factory = new JsonFactory();
    JsonParser parser = factory.createJsonParser(json);
    ObjectMapper mapper = new ObjectMapper();
   
    // will throw exception if string is not parsable json
    mapper.readTree(parser);
  }
View Full Code Here

      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();
      EncoderFactory factory = new EncoderFactory()
          .configureBlockSize(bufferSize);
View Full Code Here

      cos.flush();
     
      byte[] bb = os.toByteArray();
      // dump(bb);
      this.input = DecoderFactory.get().binaryDecoder(bb, null);
      this.parser =  f.createJsonParser(new ByteArrayInputStream(in));
    }
   
    public void scan() throws IOException {
      Stack<S> countStack = new Stack<S>();
      long count = 0;
View Full Code Here

    private Map<String, String> parseJSON(String jsonmessage){
        Map<String, String> parsed = new HashMap<String, String>();
        JsonFactory jf = new JsonFactory();
        try {
            JsonParser parser = jf.createJsonParser(jsonmessage);
            parser.nextToken(); //shift past the START_OBJECT that begins the JSON
            while (parser.nextToken() != JsonToken.END_OBJECT) {
                String fieldname = parser.getCurrentName();
                parser.nextToken(); // move to value, or START_OBJECT/START_ARRAY
                String value = parser.getText();
View Full Code Here

                JSONObject firstFileRecord = fileRecords.get(0);
                File file = ImportingUtilities.getFile(job, firstFileRecord);
                InputStream is = new FileInputStream(file);
                try {
                    JsonFactory factory = new JsonFactory();
                    JsonParser parser = factory.createJsonParser(is);

                    PreviewParsingState state = new PreviewParsingState();
                    Object rootValue = parseForPreview(parser, state);
                    if (rootValue != null) {
                        JSONUtilities.safePut(options, "dom", rootValue);
View Full Code Here

        writer.endObject();
    }
   
    static public Recon loadStreaming(String s, Pool pool) throws Exception {
        JsonFactory jsonFactory = new JsonFactory();
        JsonParser jp = jsonFactory.createJsonParser(s);
       
        if (jp.nextToken() != JsonToken.START_OBJECT) {
            return null;
        }
        return loadStreaming(jp, pool);
View Full Code Here

        }
    }
   
    static public Cell loadStreaming(String s, Pool pool) throws Exception {
        JsonFactory jsonFactory = new JsonFactory();
        JsonParser jp = jsonFactory.createJsonParser(s);
       
        if (jp.nextToken() != JsonToken.START_OBJECT) {
            return null;
        }
       
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.