{
"asks": [
[
"348.99999998",
77.078
],
[
"348.99999999",
3.12491851
]
],
"bids": [
[
"348.14449745",
12.40122304
],
[
"348.14449743",
15.00073379
]
],
"isFrozen": "0",
"seq": 187353727
}
这是字符串,类似的东西可以从here
获得我为Gson写了下面的课,但它让Gson崩溃了。
class PoloniexOrderBook {
ArrayList<Map<String, Double>> bids;
ArrayList<Map<String, Double>> asks;
String isFrozen;
int seq;
}
提前致谢。
答案 0 :(得分:1)
您的字段应该是这样的:
@SerializedName("asks")
private List<List<String>> asks = null;
@SerializedName("bids")
private List<List<String>> bids = null;
@SerializedName("isFrozen")
private String isFrozen;
@SerializedName("seq")
private Integer seq;
使用this page将JSON
转换为POJO
类。
答案 1 :(得分:-1)
方法:
JSON:{&#34;询问&#34;:[[&#34; 349.98000000&#34;,70.83367131],[&#34; 349.98021035&#34;,14.97213758]]&#34;出价& #34;:[[&#34; 349.91166666&#34;,0.00090881],[&#34; 349.90000000&#34;,2.5207202]]&#34;的isFrozen&#34;:&#34; 0&#34 ;,&#34; SEQ&#34;:187351414}
对于上面给出的JSON,POJO类应该是这样的
class PoloniexOrderBook {
@JsonProperty("asks")
private List<List<Object>> asks = null;
@JsonProperty("bids")
private List<List<Object>> bids = null;
@JsonProperty("isFrozen")
private String isFrozen;
@JsonProperty("seq")
private Integer seq;
}
可选:
如下所示创建JSON,以便它不会创建您创建的任何问题POJO类
{&#34;询问&#34;:[{&#34; 349.98000000&#34;:70.83367131,&#34; 349.98021035&#34;:14.97213758}],&#34;出价&#34 ;: [{&#34; 349.91166666&#34;:0.00090881,&#34; 349.90000000&#34;:2.5207202}],&#34;的isFrozen&#34;:&#34; 0&#34;&#34; SEQ&#34;:187351414}
POJO班级:
class PoloniexOrderBook {
ArrayList<Map<String, Double>> bids;
ArrayList<Map<String, Double>> asks;
String isFrozen;
int seq;
}