问题
Is there a way how to deserialize JSON array
{["a", "b", 1]}
into following Java class
class MyObject {
private String firstItem;
private String secondItem;
private int thirdItem;
}
ussing FasterXml jackson-databinding? I only found answers where there are key: value items in the array.
回答1:
Firstly {["a", "b", 1]}
is not a Valid Json Array (or JSON) .... JSON Array would look like this ["a", "b", 1]
Also you could deserialize the Json Array into a Java Object by writing a Custom Deserializer for the Java Object and Register it with Object Mapper using Module in Faster Xml.
Check the Following Link to get more Info on How to write Custom Deserializers
http://www.baeldung.com/jackson-deserialization
Still I would suggest not using Array Representation for an Object.
来源:https://stackoverflow.com/questions/41719860/java-fasterxml-jackson-deserialize-array-without-keys