I'm trying to deserialize json to a java entity, but I'm having trouble getting Jackson to deserialize an json array to a Pair[]. Pair is a custom class but it follows the standard form found on SO :
public class Pair<K, V> {
private final K k;
private final V v;
public Pair(K k, V v) {
this.k = k;
this.v = v;
}
public K getKey() {
return k;
}
public V getValue() {
return v;
}
...
}
The Json object can be changed as needed, but I'm trying to use something of the form:
{"priority":1,"account":"012345","tld":"com","name":"domain_check","params":[{"key":"domain","value":"domain.com"}]}
My "DefaultRequest" entity class contains:
@Entity
public class DefaultRequest implements Serializable, Comparable, Request {
//other fields...
private Pair[] params;
@Override
public Pair[] getParams() {
return params;
}
@Override
public void setParams(Pair[] params) {
this.params = params;
//other methods...
}
}
I'm sorry if someone has answered this already. I'm admittedly new to using jackson, but I've spent almost 3 days on this and I have a deadline. I also have to believe someone has had to deserialize to an entity containing a Pair[] before. Any ideas are welcome. I have complete flexibility in changing both the json format and the entity class if there is a better alternative. Thanks in advance!