Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.ObjectMapper.readValue()


    ObjectMapper om = new ObjectMapper(new YAMLFactory());
    FileInputStream fis;
    try {
      fis = new FileInputStream(args[1]);
      // Stream will be closed on completion
      this.configuration = om.readValue(fis, SiteConfiguration.class);
    } catch (IOException e) {
      throw new IllegalArgumentException("Cannot read external configuration from '"+args[1]+"'",e);
    }
  }
View Full Code Here


   *
   * @throws java.io.IOException If something goes wrong
   */
  public static String jsonFixture(String fixtureClasspath) throws IOException {
    ObjectMapper om = new ObjectMapper();
    return om.writeValueAsString(om.readValue(fixture(fixtureClasspath), JsonNode.class));
  }

  /**
   * @param fixtureClasspath The classpath (can be in other JARs)
   *
 
View Full Code Here

    else
    {
      // deserialize request body to Label
      try {
        ObjectMapper mapper = new ObjectMapper();
        label = mapper.readValue(requestJSONContent, Label.class);
      } catch (Exception e) {
        logger.info("Malformed JSON request: {}", e.getMessage());
        throw new BadRequestException("Malformed JSON request");
      }
View Full Code Here

    else
    {
      // deserialize request body to Label
      try {
        ObjectMapper mapper = new ObjectMapper();
        label = mapper.readValue(requestJSONContent, Label.class);
      } catch (Exception e) {
        logger.info("Malformed JSON request: {}", e.getMessage());
        throw new BadRequestException("Malformed JSON request");
      }
    }
View Full Code Here

public class JsonHelper {

    public static Map toMap(String json) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.readValue(json, Map.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    }

    public static Map[] toMaps(String json) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.readValue(json, Map[].class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
View Full Code Here

        return LOG;
    }

    private VersionCheckResponse parse(String httpBody) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(httpBody, VersionCheckResponse.class);
    }

    @Override
    public boolean runsForever() {
        return false;
View Full Code Here

            throw new IOException(String.format("Error getting access token: [%s: %s]",
                webResponse.getStatusCode(), webResponse.getStatusMessage()));
        }
        final long currentTime = System.currentTimeMillis();
        final ObjectMapper mapper = new ObjectMapper();
        final Map map = mapper.readValue(webResponse.getContentAsStream(), Map.class);
        final String accessToken = map.get("access_token").toString();
        final Integer expiresIn = Integer.valueOf(map.get("expires_in").toString());
        return new OAuthToken(refreshToken, accessToken,
            currentTime + TimeUnit.MILLISECONDS.convert(expiresIn, TimeUnit.SECONDS));
    }
View Full Code Here

    JsonParser jp = factory.createParser(is);

    jp.nextToken();
    mappings.clear();
    while (jp.nextToken() == JsonToken.START_OBJECT) {
      URLMapping mapping = mapper.readValue(jp, URLMapping.class);
      mappings.add(mapping);
    }
  }

  public static class URLMapping {
View Full Code Here

            // Be tolerant
            json = "{ " + json + "}";
            // json = jsonHelper.wrapJson(json);
          }

          return mapper.readValue(json, clazz);
          // return jsonHelper.unmarshal(json);
        }
      } catch (Exception e) {
        throw new OpsException("Error reading resource: " + resourceName, e);
      }
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.