美文网首页android开发
Gson解析json,没有key,不确定key,javabean

Gson解析json,没有key,不确定key,javabean

作者: e1f48f6c2de0 | 来源:发表于2017-12-27 11:42 被阅读0次

    1.没有key
    json:

    {
        "person":[
            {
                "name" : "hello",
                "childs" : ["few", "gr3"]
            },
            {
                "name" : "world",
                "childs" : ["h4w", "ku6r"]
            }
        ]
    }
    

    jsonBean:

    public class JsonBean {
    
        public ArrayList<Person> person;
    
        public static class Person{
            String name;
            ArrayList<String> childs;
        }
    }
    

    2.不确定key
    json:

    {
        "person":[
            {
                "name" : "hello",
                "childs" : [{"1":"few"}, {"2":"akuy"}]
            },
            {
                "name" : "world",
                "childs" : [{"8":"ngf"}, {"9":"y54"}]
            }
        ]
    }
    

    jsonbean:

    public class JsonBean {
    
        public ArrayList<Person> person;
    
        public static class Person{
            String name;
            ArrayList<Map<String,String>> childs;
        }
    }
    

    相关文章

      网友评论

        本文标题:Gson解析json,没有key,不确定key,javabean

        本文链接:https://www.haomeiwen.com/subject/gooygxtx.html