字符串列表中的类对象列表

时间:2015-12-03 09:28:40

标签: java spring list

我从gemfire获取数据

List<String> objects = restTemplate.getForObject(geodeURL+"/gemfire-api/v1/queries/adhoc?q=SELECT * FROM /region s",List.class);

如下所示:

[('price':'119','volume':'20000','pe':'0','eps':'4.22','week53low':'92','week53high':'134.4','daylow':'117.2','dayhigh':'119.2','movingav50day':'115','marketcap':'0','time':'2015-11-25 05:13:34.996'), ('price':'112','volume':'20000','pe':'0','eps':'9.22','week53low':'92','week53high':'134.4','daylow':'117.2','dayhigh':'119.2','movingav50day':'115','marketcap':'0','time':'2015-11-25 05:13:34.996'), ('price':'118','volume':'20000','pe':'0','eps':'1.22','week53low':'92','week53high':'134.4','daylow':'117.2','dayhigh':'119.2','movingav50day':'115','marketcap':'0','time':'2015-11-25 05:13:34.996')]

这是我得到的String列表。目前我在列表中有3个值。

我有一个像下面这样的pojo课程:

public class StockInfo {

//  @Id 
    @JsonProperty("symbol")
    private String symbol;

    @JsonProperty("price")
    private String price;

    @JsonProperty("volume")
    private String volume;

    @JsonProperty("pe")
    private String pe;

    @JsonProperty("eps")    
    private String eps;

    @JsonProperty("week53low")
    private String week53low;

    @JsonProperty("week53high")
    private String week53high;

    @JsonProperty("daylow")
    private String daylow;

    @JsonProperty("dayhigh")
    private String dayhigh;

    @JsonProperty("movingav50day")
    private String movingav50day;

    @JsonProperty("marketcap")
    private String marketcap;

    @JsonProperty("time")
    private String time;

    private String getSymbol() {
        return symbol;
    }
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }
    public String getPrice() {
        return price;
    }
    public void setPrice(String price) {
        this.price = price;
    }
    public String getVolume() {
        return volume;
    }
    public void setVolume(String volume) {
        this.volume = volume;
    }
    public String getPe() {
        return pe;
    }
    public void setPe(String pe) {
        this.pe = pe;
    }
    public String getEps() {
        return eps;
    }
    public void setEps(String eps) {
        this.eps = eps;
    }
    public String getWeek53low() {
        return week53low;
    }
    public void setWeek53low(String week53low) {
        this.week53low = week53low;
    }
    public String getWeek53high() {
        return week53high;
    }
    public void setWeek53high(String week53high) {
        this.week53high = week53high;
    }
    public String getDaylow() {
        return daylow;
    }
    public void setDaylow(String daylow) {
        this.daylow = daylow;
    }
    public String getDayhigh() {
        return dayhigh;
    }
    public void setDayhigh(String dayhigh) {
        this.dayhigh = dayhigh;
    }
    public String getMovingav50day() {
        return movingav50day;
    }
    public void setMovingav50day(String movingav50day) {
        this.movingav50day = movingav50day;
    }
    public String getMarketcap() {
        return marketcap;
    }
    public void setMarketcap(String marketcap) {
        this.marketcap = marketcap;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }

如何根据我从StockInfo

获取的值创建restTemplate.getForObject类对象的列表

1 个答案:

答案 0 :(得分:1)

我认为你可以使用:

List<StockInfo> objects = restTemplate.getForObject(geodeURL+"/gemfire-api/v1/queries/adhoc?q=SELECT * FROM /region s",List.class);