2016-10-04 54 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數組 –