Gson,Fast-Json解析 Demo

Gson

String json = "{name:'Tom',age:10,sex:'男'}";
    Gson g = new Gson();
    Student stu = g.fromJson(json, Student.class);
        System.out.println(stu);

fast:
Demo:

String json = "[{name:'Tom1',age:20,sex:'男'},{name:'Tom2',age:20,sex:'男'}]";
List list = JSON.parseArray(json, Student.class);
            System.out.println(list);

你可能感兴趣的:(Android)