这就是我所拥有的。我正在尝试反序列化一个 json,但它不起作用:
public class MyClass {
private Object attribute;
@JsonCreator
public MyClass(Object attribute) {
this.attribute = attribute;
}
@JsonProperty("attr")
public Object getAttribute() {
return attribute;
}
}
public void method() {
InputStream eventsStream = this.getClass().getClassLoader()
.getResourceAsStream("fileName.json");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.readValue(eventsStream, MyClass.class);
}
fileName.json
{
"value1": 1,
"value2": [
{
"subValue1": "valueExample"
}
]
}
我用符号“=”而不是“:”得到这个结果:
{value1=1, value2=[{subValue=valueExample}]}
它必须是一个属性或类似的东西。任何想法?谢谢