2016-10-04 59 views
0

JSON数组我在接受JSON阵列(改造)的麻烦如何获得与改造

{ "ads": [ 
    {"one": "one a", "two": "two a" }, 
     {"one": "one b", "two": "two b" }, 
      {"one": "one c", "two": "two c" }, 

    ] } 

请帮我关于Model类,以及如何获得,显示在TextView的建设或recyclerView

回答

0

您可以使用sonschema2pojo工具,能够轻松地解析JSON使用改装和/或GSON

要更多的解释,按照这个tutorial

+0

这是一个教程改造1.9 – heLL0

0

模型类将是这样的: -

Response.java

public class Response { 

    private List<AdsBean> ads; 

    public List<AdsBean> getAds() { 
     return ads; 
    } 

    public void setAds(List<AdsBean> ads) { 
     this.ads = ads; 
    } 

    private static class AdsBean { 
     private String one; 
     private String two; 

     public String getOne() { 
      return one; 
     } 

     public void setOne(String one) { 
      this.one = one; 
     } 

     public String getTwo() { 
      return two; 
     } 

     public void setTwo(String two) { 
      this.two = two; 
     } 
    } 
} 

您可以参考这个codepath guide为了得到一个想法如何与改造工作。

+0

谢谢你的帮助,但我仍然不知道它应该如何main.java,我找到了json数组 –