Confident from the Oxford vocabulary, which bypasses the means to βfind a way around (an obstacle)β, a simple job has been done here.
First, I created a method that generates the same MultiValueMap as above. And I use the same approach to parse it as a json string.
Then I created the following deserialization method
public static MultiMap<String,String> doDeserialization(String serializedString) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); Class<MultiValueMap> classz = MultiValueMap.class; MultiMap map = mapper.readValue(serializedString, classz); return (MultiMap<String, String>) map; }
Of course, this in itself refers to the exact problem that you talked about above, so I created the doDeserializationAndFormat method: it will doDeserializationAndFormat over each "list inside the list" corresponding to a given key, and bind the values ββto the key one by one
public static MultiMap<String, String> doDeserializationAndFormat(String serializedString) throws JsonParseException, JsonMappingException, IOException { MultiMap<String, String> source = doDeserialization(serializedString); MultiMap<String, String> result = new MultiValueMap<String,String>(); for (String key: source.keySet()) { List allValues = (List)source.get(key); Iterator iter = allValues.iterator(); while (iter.hasNext()) { List<String> datas = (List<String>)iter.next(); for (String s: datas) { result.put(key, s); } } } return result; }
Here is a simple call in the main method:
MultiValueMap<String,String> userParsedMap = (MultiValueMap)doDeserializationAndFormat(stackMapSerialized); System.out.println("Key 1 = " + userParsedMap.get("Key 1") ); System.out.println("Key 2 = " + userParsedMap.get("Key 2") );

Hope this helps.