Example usage for org.json JSONArray toJSONObject

List of usage examples for org.json JSONArray toJSONObject

Introduction

In this page you can find the example usage for org.json JSONArray toJSONObject.

Prototype

public JSONObject toJSONObject(JSONArray names) throws JSONException 

Source Link

Document

Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.

Usage

From source file:org.official.json.CDL.java

/**
 * Produce a JSONObject from a row of comma delimited text, using a
 * parallel JSONArray of strings to provides the names of the elements.
 * @param names A JSONArray of names. This is commonly obtained from the
 *  first row of a comma delimited text file using the rowToJSONArray
 *  method./*  ww  w  . j  a  v  a2s.  com*/
 * @param x A JSONTokener of the source text.
 * @return A JSONObject combining the names and values.
 * @throws JSONException
 */
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException {
    JSONArray ja = rowToJSONArray(x);
    return ja != null ? ja.toJSONObject(names) : null;
}