Adding List support in Item.withJSON
I'm getting following error while writing a new item in DynamoDB using DocumentAPI.
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token at [Source: [{"chargeId":"charge-1","containerChargeName":"charge-1","chargeType":"BASE","serviceProviderId":"UPS","buyerId":"AMAZON","contractType":"WAREHOUSE_TRANSFER","chargeAmount":66.67,"currencyCode":"USD"}]; line: 1, column: 1] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164) at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:691) at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:685) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:308) at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2993) Also one thing I've noticed is that Item.withJSON is transforming JSON to Map instead of List because of which I'm getting this error
Is there any way to store a JSON list in new Document API?
You can do it today by JSON-parsing the String into a List> yourself and passing it to Item.withList, but it'd definitely be nice to support this out of the box - either by adding an explicit withJsonArray or having withJson try to figure out whether the input is an array or object. We'll add this to our backlog, or we'd be happy to look at a pull request.
Please review my PR for this issue: https://github.com/aws/aws-sdk-java/pull/688
@david-at-aws Can you take a look at the PR above?
@david-at-aws is no longer at aws, but the change looks reasonable to me.
The PR is merged, closing this issue.