How to convert a JSON string to a Map with Jackson JSON

I’m trying to do something like this but it doesn’t work:

Map<String, String> propertyMap = new HashMap<String, String>();

propertyMap = JacksonUtils.fromJSON(properties, Map.class);

But the IDE says:

Unchecked assignment Map to Map<String,String>

What’s the right way to do this?
I’m only using Jackson because that’s what is already available in the project, is there a native Java way of converting to/from JSON?

In PHP I would simply json_decode($str) and I’d get back an array. I need basically the same thing here.

11 Answers
11

Leave a Comment