且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java:Jackson数据绑定无法从JSON文件映射整个类

更新时间:2023-01-17 08:16:59

再一次就像推文的情况一样,你没有将数据加载到'用户'对象。而不是:

Once again, just like in the case with tweets, you're not loading data to 'user' object. Instead of:

user = tweet.new User();

你应该使用:

user = tweet.getUser();

您的推文类中也缺少以下内容:

You're also missing the following in your Tweet class:

@JsonProperty("user")
private User user;
public User getUser() { return user; }

我不知道你是如何生成你的Tweets.java文件的,但它没有'似乎是完整的。考虑使用 http://www.jsonschema2pojo.org/ 重新生成它。

I don't know how you've generated your Tweets.java file, but it doesn't seem to be complete. Consider using http://www.jsonschema2pojo.org/ to re-generate it.