は、私はそれがFooのエンティティの配列があります。このJSONファイルジャクソンResourceAccessException:I/Oエラー:認識できないフィールド
[
{
"foo":{
"comment":null,
"media_title":"How I Met Your Mother",
"user_username":"nani"
}
},
{
"foo":{
"comment":null,
"media_title":"Family Guy",
"user_username":"nani"
}
}
]
を持っています。次のように私は私のFooTemplateを持って
その後import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
@JsonRootName("foo")
public class Foo {
@JsonProperty
String comment;
@JsonProperty("media_title")
String mediaTitle;
@JsonProperty("user_username")
String userName;
/** setters and getters go here **/
}
:
は、その後、私は私のFooオブジェクトを持っている
public List<Foo> getFoos() {
return java.util.Arrays.asList(restTemplate.getForObject(buildUri("/foos.json"),
Foo[].class));
}
をしかし、私は私の簡単なテストを実行したときに私が取得:
org.springframework.web.client.ResourceAccessException: I/O error: Unrecognized field "foo" (Class org.my.package.impl.Foo), not marked as ignorable at [Source: [email protected]; line: 3, column: 14] (through reference chain: org.my.package.impl.Foo["foo"]);
残念ながら、それは "私自身の" jsonではありません。私はまた、それが壊れたjsonのようだと思ったが、それは公共のapiなので、私は "ナ..."できないようだった。おそらく私はこれらの人にそれについて尋ねるべきだと思います。多分それは実際に彼らのバグです – user1168098
別の提案のために私の編集を見てください。 –
大丈夫です。私はあなたの提案とFooオブジェクトプロパティを含むFooMixinオブジェクトに従った。ありがとう – user1168098