android FastJson的使用

阿里巴巴FastJson是一个Json处理工具包,包括“序列化”和“反序列化”两部分,它是目前速度最快json解析类。


 public static T getPerson(String jsonString, Class cls) {
        T t = null;
        try {
            t = JSON.parseObject(jsonString, cls);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return t;
    }
public static List getPersons(String jsonString, Class cls) {
        List list = new ArrayList();
        try {
            list = JSON.parseArray(jsonString, cls);
        } catch (Exception e) {
        }
        return list;
    }
public static List listKeyMaps(String jsonString) {
        List list = new ArrayList();
        try {
            list = JSON.parseObject(jsonString,
                    new TypeReference>() {
            });

        } catch (Exception e) {
            // TODO: handle exception
        }
        return list;
    }

你可能感兴趣的:(android)