Package com.fasterxml.jackson.databind

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


    public void testContainer() throws IOException {
        final Fixture expected = new Fixture();
        final String str = writer.writeValueAsString(expected);
        Assert.assertTrue(str.contains("DEBUG"));
        final ObjectReader fixtureReader = log4jObjectMapper.reader(Fixture.class);
        final Fixture actual = fixtureReader.readValue(str);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testNameOnly() throws IOException {
View Full Code Here


        tokenPost.setEntity(new StringEntity(entity, "UTF-8"));
        CloseableHttpResponse resp1 = httpclient.execute(tokenPost);
        ObjectReader jreader = Utils.getJsonReader(Map.class);

        if (resp1 != null && resp1.getEntity() != null) {
          Map<String, Object> token = jreader.readValue(resp1.getEntity().getContent());
          if (token != null && token.containsKey("access_token")) {
            // got valid token
            HttpGet profileGet = new HttpGet(PROFILE_URL);
            profileGet.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token.get("access_token"));
            CloseableHttpResponse resp2 = httpclient.execute(profileGet);
View Full Code Here

            CloseableHttpResponse resp2 = httpclient.execute(profileGet);
            HttpEntity respEntity = resp2.getEntity();
            String ctype = resp2.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();

            if (respEntity != null && Utils.isJsonType(ctype)) {
              Map<String, Object> profile = jreader.readValue(resp2.getEntity().getContent());

              if (profile != null && profile.containsKey("sub")) {
                String googleSubId = (String) profile.get("sub");
                String pic = (String) profile.get("picture");
                String email = (String) profile.get("email");
View Full Code Here

        HttpPost tokenPost = new HttpPost(url);
        CloseableHttpResponse resp1 = httpclient.execute(tokenPost);
        ObjectReader jreader = Utils.getJsonReader(Map.class);

        if (resp1 != null && resp1.getEntity() != null) {
          Map<String, Object> token = jreader.readValue(resp1.getEntity().getContent());
          if (token != null && token.containsKey("access_token")) {
            // got valid token
            HttpGet profileGet = new HttpGet(PROFILE_URL + token.get("access_token"));
            CloseableHttpResponse resp2 = httpclient.execute(profileGet);
            HttpEntity respEntity = resp2.getEntity();
View Full Code Here

            CloseableHttpResponse resp2 = httpclient.execute(profileGet);
            HttpEntity respEntity = resp2.getEntity();
            String ctype = resp2.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();

            if (respEntity != null && Utils.isJsonType(ctype)) {
              Map<String, Object> profile = jreader.readValue(resp2.getEntity().getContent());

              if (profile != null && profile.containsKey("id")) {
                String linkedInID = (String) profile.get("id");
                String email = (String) profile.get("emailAddress");
                String pic = (String) profile.get("pictureUrl");
View Full Code Here

            CloseableHttpResponse resp2 = httpclient.execute(profileGet);
            HttpEntity respEntity = resp2.getEntity();
            String ctype = resp2.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();

            if (respEntity != null && Utils.isJsonType(ctype)) {
              Map<String, Object> profile = jreader.readValue(resp2.getEntity().getContent());

              if (profile != null && profile.containsKey("id")) {
                String fbId = (String) profile.get("id");
                Map<String, Object> pic = (Map<String, Object>) profile.get("picture");
                String email = (String) profile.get("email");
View Full Code Here

    @Override
    public <T> T fromJSON(String s, Class<T> aClass) {
        try {
            final ObjectReader reader = mapper.reader(aClass);

            return reader.readValue(s);
        } catch (IOException e) {
            throw Exceptions.runtime(e);
        }
    }
View Full Code Here

        if (type != null)
            reader = mapper.reader(type);
        else
            reader = mapper.reader();

        return reader.readValue(json);
    }
   
    public <T> Collection<T> deSerCollection2(String json, Class<? extends Collection> collectionClass, Class<T> type)
            throws Exception {
        return mapper.readValue(json, mapper.getTypeFactory()
View Full Code Here

  public static boolean update(final Object value, final String json) {

    try {

      final ObjectReader reader = JsonUtil.json.readerForUpdating(value);
      reader.readValue(json);

      return true;
    } catch (final Exception e) {
      log.error("", e);
      return false;
View Full Code Here

        }
      }
    }

    ObjectReader jsonReader = mapper.readerForUpdating(existingObject);
    jsonReader.readValue(root);

    return existingObject;
  }

  /**
 
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.