Package org.codehaus.jackson

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


    else
      url += "json?pagetoken=" + nextPageToken;
    url += "&key=" + _key + "&sensor=false";
   
    try {
      JsonParser parser = factory.createJsonParser(new URL(url));
      // loop until token equal to "}"
      while (parser.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = parser.getCurrentName();
        if ("html_attributions".equals(fieldname)) {
          parser.nextToken();
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

  @Nonnull
  public T deserialize( @Nonnull InputStream in, @Nullable Version version ) throws IOException, VersionException {
    try {
      JsonFactory jsonFactory = JacksonSupport.getJsonFactory();
      JsonParser parser = jsonFactory.createJsonParser( in );

      T deserialized = deserializeInternal( parser, version );

      ensureParserClosed( parser );
      return deserialized;
View Full Code Here

  private Reader reader;

  public JsonFilterReader( Reader reader ) throws IOException {
    this.reader = reader;
    JsonFactory parserFactory = new JsonFactory();
    parser = parserFactory.createJsonParser( reader );
    writer = new StringWriter();
    buffer = writer.getBuffer();
    offset = 0;
    generator = parserFactory.createJsonGenerator( writer );
  }
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;
View Full Code Here

    }

    public static JsonParser createJsonParser(String content) {
        JsonFactory jsonFactory = getJsonFactory();
        try {
            return jsonFactory.createJsonParser(content);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

    }

    public static JsonParser createJsonParser(InputStream content) {
        JsonFactory jsonFactory = getJsonFactory();
        try {
            return jsonFactory.createJsonParser(content);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

    }

    public static JsonParser createJsonParser(Reader content) {
        JsonFactory jsonFactory = getJsonFactory();
        try {
            return jsonFactory.createJsonParser(content);
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

    }

    @Test
    public void testParseLocation() throws Exception {
        JsonFactory jfactory = new JsonFactory();
        JsonParser jParser = jfactory.createJsonParser(new StringReader("{\n" +
                                                                        "    \"timestampMs\" : \"1376053800229\",\n" +
                                                                        "    \"latitudeE7\" : 508261000,\n" +
                                                                        "    \"longitudeE7\" : 43543660,\n" +
                                                                        "    \"accuracy\" : 10\n" +
                                                                        "  }"));
View Full Code Here

    }
   
    public static String indentJSON(final String jsonIn) throws JSONParseException{
        JsonFactory fac = new JsonFactory();
        try{
            JsonParser parser = fac.createJsonParser(new StringReader(jsonIn));
            ObjectMapper mapper = new ObjectMapper();
            JsonNode node = null;
            try{
                node = mapper.readTree(parser);
            }
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.