How to convert JSON to Java Map Object

By |2018-04-25T03:12:00+05:30May 18th, 2017|json|

Here I am going to show you how to convert a JSON to Java Map object using Jackson.

JSON to Java Map :

In the previous tutorials we have seen how to convert a Java object to JSON string, you can see the required Jackson dependencies there.

Here I am going to create a JSON string and convert it into Java’s java.util.Map object.

package com.onlinetutorialspoint.json;

import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.type.TypeReference;

public class JSON_String_TO_Map {
    public static void main(String[] a) {

        ObjectMapper mapperObj = new ObjectMapper();
        Map<String,String> jsonMap = new HashMap<String,String>(); 
        try {
            jsonMap = mapperObj.readValue(jsonString(),
                    new TypeReference<HashMap<String,String>>(){});

        } catch (Exception e) {
    public static String jsonString() {
        String str = "{\"studentId\": 1001, \"studentName\": \"Rajesh\","
                + "\"roleNumber\": \"106\",\"standard\": \"11th\"}";
        return str;



{studentId=1001, standard=11th, studentName=Rajesh, roleNumber=106}

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment