Search in sources :

Example 21 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class TopDao method mapperJson.

public List<Object> mapperJson(boolean useCache) {
    List<Object> topCategorys = new ArrayList<Object>();
    tabs.clear();
    try {
        String resultNews = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_NEWS_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        NewsMoreResponse newsMoreResponse = mObjectMapper.readValue(resultNews, new TypeReference<NewsMoreResponse>() {
        });
        if (newsMoreResponse != null) {
            this.newsCategorys = newsMoreResponse.getResponse();
        }
        String resultBlogs = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_BLOG_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        BlogsMoreResponse blogsMoreResponse = mObjectMapper.readValue(resultBlogs, new TypeReference<BlogsMoreResponse>() {
        });
        if (blogsMoreResponse != null) {
            this.blogsCategorys = blogsMoreResponse.getResponse();
        }
        String resultWiki = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_WIKI_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        WikiMoreResponse wikiMoreResponse = mObjectMapper.readValue(resultWiki, new TypeReference<WikiMoreResponse>() {
        });
        if (wikiMoreResponse != null) {
            this.wikiCategorys = wikiMoreResponse.getResponse();
        }
        Collections.addAll(topCategorys, newsCategorys, blogsCategorys, wikiCategorys);
        return topCategorys;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) BlogsMoreResponse(cn.eoe.app.entity.BlogsMoreResponse) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) WikiMoreResponse(cn.eoe.app.entity.WikiMoreResponse) NewsMoreResponse(cn.eoe.app.entity.NewsMoreResponse)

Example 22 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class UserDao method mapperJson.

public UserResponse mapperJson(String key) {
    // TODO Auto-generated method stub
    UserJson userJson;
    try {
        if (!key.contains(":")) {
            return null;
        }
        String url = String.format(Urls.KEYBindURL, key) + Utility.getParams(key);
        String result = HttpUtils.getByHttpClient(mContext, url);
        userJson = mObjectMapper.readValue(result, new TypeReference<UserJson>() {
        });
        if (userJson == null) {
            return null;
        }
        return userJson.getResponse();
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : UserJson(cn.eoe.app.entity.UserJson) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException)

Example 23 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class BlogsDao method mapperJson.

public BlogsResponseEntity mapperJson(boolean useCache) {
    BlogsJson blogsJson_;
    try {
        String result = RequestCacheUtil.getRequestContent(mActivity, Urls.BLOGS_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        blogsJson_ = mObjectMapper.readValue(result, new TypeReference<BlogsJson>() {
        });
        if (blogsJson_ == null) {
            return null;
        }
        _blogsResponse = blogsJson_.getResponse();
        return _blogsResponse;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : JsonMappingException(org.codehaus.jackson.map.JsonMappingException) BlogsJson(cn.eoe.app.entity.BlogsJson) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException)

Example 24 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project gravel by gravel-st.

the class StringExtensions method parseAsJSONValue.

public static Map<String, Object> parseAsJSONValue(String src) {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode rootNode;
    try {
        rootNode = (ObjectNode) mapper.readValue(src, JsonNode.class);
    } catch (JsonParseException e) {
        throw new RuntimeException(e);
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    HashMap<String, Object> map = new HashMap<String, Object>();
    for (Iterator<Entry<String, JsonNode>> iter = rootNode.getFields(); iter.hasNext(); ) {
        Entry<String, JsonNode> field = iter.next();
        JsonNode value = field.getValue();
        Object o = jsonNodeAsSimpleObject(value);
        map.put(field.getKey(), o);
    }
    return map;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) HashMap(java.util.HashMap) JsonNode(org.codehaus.jackson.JsonNode) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) Entry(java.util.Map.Entry) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 25 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project wonderdog by infochimps-labs.

the class ElasticSearchStorage method putNext.

/**
       Here we handle both the delimited record case and the json case.
     */
@SuppressWarnings("unchecked")
@Override
public void putNext(Tuple t) throws IOException {
    UDFContext context = UDFContext.getUDFContext();
    Properties property = context.getUDFProperties(ResourceSchema.class);
    MapWritable record = new MapWritable();
    String isJson = property.getProperty(ES_IS_JSON);
    // Handle delimited records (ie. isJson == false)
    if (isJson != null && isJson.equals("false")) {
        String[] fieldNames = property.getProperty(PIG_ES_FIELD_NAMES).split(COMMA);
        for (int i = 0; i < t.size(); i++) {
            if (i < fieldNames.length) {
                try {
                    record.put(new Text(fieldNames[i]), new Text(t.get(i).toString()));
                } catch (NullPointerException e) {
                //LOG.info("Increment null field counter.");
                }
            }
        }
    } else {
        if (!t.isNull(0)) {
            String jsonData = t.get(0).toString();
            // parse json data and put into mapwritable record
            try {
                HashMap<String, Object> data = mapper.readValue(jsonData, HashMap.class);
                record = (MapWritable) toWritable(data);
            } catch (JsonParseException e) {
                e.printStackTrace();
            } catch (JsonMappingException e) {
                e.printStackTrace();
            }
        }
    }
    try {
        writer.write(NullWritable.get(), record);
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
}
Also used : UDFContext(org.apache.pig.impl.util.UDFContext) IOException(java.io.IOException) Properties(java.util.Properties) JsonParseException(org.codehaus.jackson.JsonParseException) InterruptedException(java.lang.InterruptedException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException)

Aggregations

JsonMappingException (org.codehaus.jackson.map.JsonMappingException)39 IOException (java.io.IOException)31 JsonParseException (org.codehaus.jackson.JsonParseException)30 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)14 TypeReference (org.codehaus.jackson.type.TypeReference)10 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 Map (java.util.Map)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 BlogsMoreResponse (cn.eoe.app.entity.BlogsMoreResponse)2 NewsMoreResponse (cn.eoe.app.entity.NewsMoreResponse)2 WikiMoreResponse (cn.eoe.app.entity.WikiMoreResponse)2 ByteString (com.linkedin.data.ByteString)2 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)2 InputStream (java.io.InputStream)2 MessagingException (javax.mail.MessagingException)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 MimeMultipart (javax.mail.internet.MimeMultipart)2