Package org.codehaus.jackson

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


  }

  public static OGCGeometry fromJson(String string)
      throws JsonParseException, IOException {
    JsonFactory factory = new JsonFactory();
    JsonParser jsonParserPt = factory.createJsonParser(string);
    jsonParserPt.nextToken();
    MapGeometry mapGeom = GeometryEngine.jsonToGeometry(jsonParserPt);
    return OGCGeometry.createFromEsriGeometry(mapGeom.getGeometry(),
        mapGeom.getSpatialReference());
  }
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

    @Override
    public T unmarshall(Class<T> clazz, String obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
            return jsonParser.readValueAs(clazz);
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    @Override
    public T unmarshall(Class<T> clazz, String obj) {
        try {
            JsonFactory jsonFactory = new MappingJsonFactory();
            JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(obj));
            return jsonParser.readValueAs(clazz);
        } catch ( Exception e ) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

  }
 
  void testJsonEquivalence(String actual, String expected)throws Exception{
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory factory = mapper.getJsonFactory();
    JsonParser jp = factory.createJsonParser(actual);
    JsonNode actualObj = mapper.readTree(jp);
   
    jp = factory.createJsonParser(expected);
    JsonNode  expectedObj = mapper.readTree(jp);
    assertEquals(actualObj, expectedObj);
View Full Code Here

    ObjectMapper mapper = new ObjectMapper();
    JsonFactory factory = mapper.getJsonFactory();
    JsonParser jp = factory.createJsonParser(actual);
    JsonNode actualObj = mapper.readTree(jp);
   
    jp = factory.createJsonParser(expected);
    JsonNode  expectedObj = mapper.readTree(jp);
    assertEquals(actualObj, expectedObj);
  }
}
View Full Code Here

        return result;
    }

    public static Build jsonStringToBuildInfo(String json) throws IOException {
        JsonFactory jsonFactory = createJsonFactory();
        JsonParser parser = jsonFactory.createJsonParser(new StringReader(json));
        return jsonFactory.getCodec().readValue(parser, Build.class);
    }

    public static <T extends Serializable> String buildInfoToJsonString(T buildComponent) throws IOException {
        JsonFactory jsonFactory = createJsonFactory();
View Full Code Here

        return result;
    }

    public static <T extends Serializable> T jsonStringToGeneric(String json, Class<T> clazz) throws IOException {
        JsonFactory jsonFactory = createJsonFactory();
        JsonParser parser = jsonFactory.createJsonParser(new StringReader(json));
        return jsonFactory.getCodec().readValue(parser, clazz);
    }

    public static void saveBuildInfoToFile(Build build, File toFile) throws IOException {
        String buildInfoJson = buildInfoToJsonString(build);
View Full Code Here

        return ArtifactoryVersion.NOT_FOUND;
    }

    public JsonParser createJsonParser(InputStream in) throws IOException {
        JsonFactory jsonFactory = createJsonFactory();
        return jsonFactory.createJsonParser(in);
    }

    public JsonFactory createJsonFactory() {
        JsonFactory jsonFactory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper(jsonFactory);
View Full Code Here

            if (assumptionFile.isFile())
            {
                try
                {
                    JsonFactory f = new JsonFactory();
                    JsonParser p = f.createJsonParser(assumptionFile);
                    JsonToken token = p.nextToken();
                    while (token != JsonToken.END_OBJECT)
                    {
                        if (token == JsonToken.FIELD_NAME)
                        {
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.