首页 > Web开发 > 详细

学习笔记:fastjson-1

时间:2016-12-27 22:52:10      阅读:236      评论:0      收藏:0      [点我收藏+]
 1     public int size() {
 2         return map.size();
 3     }
 4     public boolean isEmpty() {
 5         return map.isEmpty();
 6     }
 7     public boolean containsKey(Object key) {
 8         return map.containsKey(key);
 9     }
10     public boolean containsValue(Object value) {
11         return map.containsValue(value);
12     }
13     public Object get(Object key) {
14         return map.get(key);
15     }
16     public JSONObject getJSONObject(String key) {
17         Object value = map.get(key);
18         if (value instanceof JSONObject) {
19             return (JSONObject) value;
20         }
21         if (value instanceof String) {
22             return JSON.parseObject((String) value);
23         }
24         return (JSONObject) toJSON(value);
25     }
26     public JSONArray getJSONArray(String key) {
27         Object value = map.get(key);
28         if (value instanceof JSONArray) {
29             return (JSONArray) value;
30         }
31         if (value instanceof String) {
32             return (JSONArray) JSON.parse((String) value);
33         }
34         return (JSONArray) toJSON(value);
35     }

将可能常用的fastjson函数列在这里方便查看。

    public int size() {

        return map.size();

    }

    public boolean isEmpty() {

        return map.isEmpty();

    }

    public boolean containsKey(Object key) {

        return map.containsKey(key);

    }

    public boolean containsValue(Object value) {

        return map.containsValue(value);

    }

    public Object get(Object key) {

        return map.get(key);

    }

    public JSONObject getJSONObject(String key) {

        Object value = map.get(key);

        if (value instanceof JSONObject) {

            return (JSONObject) value;

        }

        if (value instanceof String) {

            return JSON.parseObject((String) value);

        }

        return (JSONObject) toJSON(value);

    }

    public JSONArray getJSONArray(String key) {

        Object value = map.get(key);

        if (value instanceof JSONArray) {

            return (JSONArray) value;

        }

        if (value instanceof String) {

            return (JSONArray) JSON.parse((String) value);

        }

        return (JSONArray) toJSON(value);

    }

学习笔记:fastjson-1

原文:http://www.cnblogs.com/FightingMan/p/6227544.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!