Hello everyone,
I have marshalled an object with jackson and I'm trying unmarshall the
generated json back to java and it does not seem to work.
The object contains a single attribute which is a an ArrayList:
*public* *class* CacheStore *implements* Serializable {
*private* ArrayList<CacheItem> store;
}
The CacheItem has two attributes:
*public class CacheItem implements Serializable {*
* private PacsBean entry;*
* private MessageKey key;*
* }*
When marshalled, the generated json output is bellow:
*[ {*
* "entry" : {"msgId" : "msg01","transactionId" : "001","instructionId" :
"instr001"},*
* "key" : {"id" : "id1","bicCode" : "code1"}*
*},*
* {*
*"entry" : {"msgId" : "msg02","transactionId" : "002","instructionId" :
"instr002"},*
* "key" : {"id" : "id1","bicCode" : "code1"}*
*}*
* ]*
When I try to unmarshall the json above, I'm expected to get a CacheStore
with a store attribute containing the ArrayList of CacheItem.
The instruction that I'm using to unmarshall the json is the following:
ObjectMapper mapper = new ObjectMapper();
String jsonInput = BACKUP_LOCATION_FOLDER +"cachestore.json";
CacheStore cacheStore = mapper.readValue(new File(jsonInput),
CacheStore.class);
*I'm getting he following exception when I execute the instruction:*
*Exception in thread "main"
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize value of type `com.redhat.consulting.jdg.model.CacheStore` from
Array value (token `JsonToken.START_ARRAY`)*
* at [Source: (File); line: 1, column: 1]*
* at
com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)*
* at
com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1603)*
Is there something I'm missing in the instruction?
Do I need to change the CacheStore object?
Any input is appre
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/40591ce0-944a-40b2-8e2e-be10d2143574n%40googlegroups.com.