Android 利用fastjson进行json解析

package com.example.FastJson.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.List;
import java.util.Map;

/**
 * Created by chang on 14-10-3.
 */
public class jsonUtil {

    public static <T> T getObject(String jsonString, Class<T> cls) {
        return JSON.parseObject(jsonString,cls);
    }

    public static <T> List<T> getObjects(String jsonString, Class<T> cls) {
        return JSON.parseArray(jsonString,cls);
    }

    public static List<Map<String,String>> getKeyMapsList(String jsonString) {
        List<Map<String,String>> list;
        list = JSON.parseObject(jsonString, new TypeReference<List<Map<String, String>>>(){});
        return list;
    }
}

posted @ 2017-08-07 20:13  jhcelue  阅读(673)  评论(0编辑  收藏  举报