0

I have a jsonString which is a list of key value pairs.

[
 {"id": "123", "url": "ghi"} : 2,
 {"id": "456", "url": "def"} : 3
]

How to convert to HashMap. Maps:

Key - {"id": "123", "url": "ghi"} value - 2 Key - {"id": "456", "url": "def"} value - 3

The key issue here is that the Key is a composite type and not a simple datatype

3
  • This question is similar to: creating Hashmap from a JSON String. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Mar 24 at 13:34
  • No my question is for a json which contains list of key value pair. The key is a complex type and the value is Integer type Map<ComplexDataClass,Integer> fileObjects = mapper.readValue(jsonString, new TypeReference<Map<ComplexDataClass,Integer>>(){}); Commented Mar 24 at 13:51
  • @TanyaBhandari The key issue is that your "json string" does not contain valid JSON; it's something else that's not JSON. Commented Jul 16 at 11:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.