我正在尝试使用 GSON 将一些 JSON 解析为 Java 对象。我的 json 在这里:http ://ec2-50-112-212-186.us-west-2.compute.amazonaws.com/ske.json
以下是我的 Java bean。我在JsonGen的帮助下创建了它:
package ske.entities;
import java.util.List;
public class WordSketch{
private List<Gramrels> gramrels;
private String corp_full_name;
public String getCorp_full_name() {
return corp_full_name;
}
public void setCorp_full_name(String corp_full_name) {
this.corp_full_name = corp_full_name;
}
public List<Gramrels> getGramrels(){
return this.gramrels;
}
public void setGramrels(List<Gramrels> gramrels){
this.gramrels = gramrels;
}
public static class Gramrels {
private List<Words> words;
private Number count;
private String name;
private Number score;
private Number seek;
public List<Words> getWords(){
return this.words;
}
public void setWords(List<Words> words){
this.words = words;
}
public Number getCount(){
return this.count;
}
public void setCount(Number count){
this.count = count;
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name = name;
}
public Number getScore(){
return this.score;
}
public void setScore(Number score){
this.score = score;
}
public Number getSeek(){
return this.seek;
}
public void setSeek(Number seek){
this.seek = seek;
}
}
public static class Words {
private Number count;
private Number id;
private String lempos;
private Number score;
private Number seek;
private String word;
public Number getCount(){
return this.count;
}
public void setCount(Number count){
this.count = count;
}
public Number getId(){
return this.id;
}
public void setId(Number id){
this.id = id;
}
public String getLempos(){
return this.lempos;
}
public void setLempos(String lempos){
this.lempos = lempos;
}
public Number getScore(){
return this.score;
}
public void setScore(Number score){
this.score = score;
}
public Number getSeek(){
return this.seek;
}
public void setSeek(Number seek){
this.seek = seek;
}
public String getWord(){
return this.word;
}
public void setWord(String word){
this.word = word;
}
}
}
但是,当我调用填充但WordSketch gramrels = gson.fromJson(new InputStreamReader(response.getEntity().getContent()), WordSketch.class);
为空时。我究竟做错了什么?corp_full_name
gramrels
这是我第一次使用 Json,所以我还是新手。
谢谢,