Here you can find the source of fill_dictionary(Map
private static void fill_dictionary(Map<String, Object> dictionary, JsonObject jsonObject)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import javax.json.JsonArray; import javax.json.JsonObject; import javax.json.JsonValue; public class Main { private static void fill_dictionary(Map<String, Object> dictionary, JsonObject jsonObject) { if (dictionary == null || jsonObject == null) { return; }//from w w w . jav a 2 s. c o m for (String key : jsonObject.keySet()) { JsonValue valueObj = (JsonValue) jsonObject.get(key); JsonValue.ValueType type = valueObj.getValueType(); if (type == JsonValue.ValueType.ARRAY) { JsonArray arrayObj = jsonObject.getJsonArray(key); ArrayList<Object> array = new ArrayList<Object>(); for (int i = 0; i < arrayObj.size(); i++) { Map<String, Object> entryDictionary = new HashMap<String, Object>(); fill_dictionary(entryDictionary, arrayObj.getJsonObject(i)); array.add(entryDictionary); } dictionary.put(key, array); } else if (type == JsonValue.ValueType.OBJECT) { Map<String, Object> entryDictionary = new HashMap<String, Object>(); fill_dictionary(entryDictionary, jsonObject.getJsonObject(key)); dictionary.put(key, entryDictionary); } else if (type == JsonValue.ValueType.STRING) { dictionary.put(key, jsonObject.getString(key)); } else if (type == JsonValue.ValueType.NUMBER) { dictionary.put(key, new Long(jsonObject.getJsonNumber(key).longValue())); } else if (type == JsonValue.ValueType.TRUE) { dictionary.put(key, Boolean.TRUE); } else if (type == JsonValue.ValueType.FALSE) { dictionary.put(key, Boolean.FALSE); } } } }