Android JSON Get JSONToMap(JSONObject obj)

Here you can find the source of JSONToMap(JSONObject obj)

Description

JSON To Map

License

Open Source License

Declaration

public static Map<String, String> JSONToMap(JSONObject obj)
            throws JSONException 

Method Source Code

//package com.java2s;
/* /*from   www.j  a v a  2s  . co  m*/
 * SWRVE CONFIDENTIAL
 * 
 * (c) Copyright 2010-2014 Swrve New Media, Inc. and its licensors.
 * All Rights Reserved.
 * 
 * NOTICE: All information contained herein is and remains the property of Swrve
 * New Media, Inc or its licensors.  The intellectual property and technical
 * concepts contained herein are proprietary to Swrve New Media, Inc. or its
 * licensors and are protected by trade secret and/or copyright law.
 * Dissemination of this information or reproduction of this material is
 * strictly forbidden unless prior written permission is obtained from Swrve.
 */

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;

import java.util.Map;

public class Main {
    public static Map<String, String> JSONToMap(JSONObject obj)
            throws JSONException {
        Map<String, String> map = new HashMap<String, String>();
        @SuppressWarnings("unchecked")
        Iterator<String> it = obj.keys();
        while (it.hasNext()) {
            String key = it.next();
            map.put(key, obj.getString(key));
        }
        return map;
    }
}

Related

  1. getObjectArray(JSONArray jsonArray, Class clazz)
  2. jsonToDate(String jsonString)
  3. jsonToByteBuffer(JSONObject jsonObj)