我正在尝试使用 gson 从URL读取 json ,但似乎有问题。这是我的代码:String url = "...";
com.google.gson.JsonObject jsonObject = new JsonParser().parse(url).getAsJsonObject();
String fajr = jsonObject.getAsJsonObject("data").getAsJsonObject("timings").get("Fajr").getAsString();
System.out.println(fajr);错误:Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 6 path $
at com.google.gson.JsonParser.parse(JsonParser.java:65)
...
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 6 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)
...
at com.google.gson.JsonParser.parse(JsonParser.java:60)
... 2 more
1 回答
繁花不似锦
TA贡献1851条经验 获得超4个赞
@Entity
@Table(name = "MYENTITYTABLE")
public class MyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// out commented the sequence generator
@Column(name="KGB_NR")
private long kgbNr;
@Column(name="KGB_UUID")
private String kgbUuid; // <<== DEFINED AS STRING!
//bi-directional many-to-one association to Ekistnutzer
@ManyToOne
@JoinColumn(name="EKN_NR")
private EkistnutzerEntity ekistnutzer;
// Other attributes not related in problem
}
添加回答
举报
0/150
提交
取消