Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

import org.json.JSONObject;

import android.util.Log;

public class Main {

    public static HashMap<String, String> jsonObject2HashMap(JSONObject jsonObject) {
        HashMap<String, String> hashMap = new HashMap<String, String>();
        Iterator<String> iterator = jsonObject.keys();

        try {
            while (iterator.hasNext()) {
                String key = iterator.next();
                String value = jsonObject.getString(key);
                hashMap.put(key, value);

            }
        } catch (Exception e) {
            Log.w("apputil", "jsonobject2hasmap");
        }
        return hashMap;
    }
}