JsonMappingException no single-String constructor/factory method Jackson

jackson, java, json, spring-mvc

Solution

As comments mentioned, your JSON contains `Map<String,String>` and NOT `Map<String,CartDataHelper>`: values are JSON Strings, not JSON Objects.

Ideally you would not try writing out objects as JSON Strings; and if so, things would work.

Problem

I am trying to parse JSON data being sent from UI in my Controller using Spring build Jackson support and this is my code ``` final Map<String, CartDataHelper> entriesToUpdateMap = new ObjectMapper().readValue(entriesToUpdate, new TypeReference<Map<String, CartDataHelper>>() ``` my JSON string is ``` {"0":"{\"categoryCode\":\"shoes\",\"productCode\":\"300050253\",\"initialQty\":\"3\",\"leftoverQty\":\"0\",\"newQty\":\"3\"}", "1":"{\"categoryCode\":\"shoes\",\"productCode\":\"300050254\",\"initialQty\":\"3\",\"leftoverQty\":\"0\",\"newQty\":\"3\"}"} ``` i checked the JSON format using some online services and it seems valid, while tryin gto parse JSON data i am getting following exception ``` org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class controllers.util.CartDataHelper] from JSON String; no single-String constructor/factory method ``` my `CartDataHelper` class contains simple properties for for `productCode`, `categoryCode` etc with a no argument constructor

Original source