Java Json Parse parseJson(String jsonText, String[] params)

Here you can find the source of parseJson(String jsonText, String[] params)

Description

parse Json

License

CDDL license

Declaration

protected static Map<String, Object> parseJson(String jsonText, String[] params)
        throws JSONException, ParseException 

Method Source Code

//package com.java2s;
/**//from w w  w  . j a  v  a2 s . c  o  m
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 * You may obtain a copy of the License at
    
 *  http://www.zhuangxulin.com/licenses/LICENSE-1.0
      
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

import java.text.ParseException;
import java.util.HashMap;

import java.util.Map;

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

public class Main {

    protected static Map<String, Object> parseJson(String jsonText, String[] params)
            throws JSONException, ParseException {
        JSONObject jo = new JSONObject(jsonText);
        Map<String, Object> result = new HashMap<String, Object>();
        for (int i = 0; i < params.length; i++) {
            result.put(params[i], jo.get(params[i]));
        }
        return result;
    }
}

Related

  1. json2Obj(String json, Class clazz)
  2. jsonString(String s)
  3. parse(JSONObject jsonobj)
  4. parse(String json, Class tClass)
  5. parseDateFromJsonArray(final JsonArray array)
  6. parseJSONDate(String _dateStr)