congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JSONArray.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
us.monoid.json.JSONArray

Best Java code snippets using us.monoid.json.JSONArray.get (Showing top 20 results out of 315)

origin: us.monoid.web/resty

/**
 * Get the string associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return A string value.
 * @throws JSONException
 *           If there is no value for the index.
 */
public String getString(int index) throws JSONException {
  return get(index).toString();
}
origin: beders/Resty

/**
 * Get the int value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number. if the value cannot be converted to a number.
 */
public int getInt(int index) throws JSONException {
  Object o = get(index);
  return o instanceof Number ? ((Number) o).intValue() : (int) getDouble(index);
}
origin: beders/Resty

sb.append('>');
do {
  e = ja.get(i);
  i += 1;
  if (e != null) {
origin: beders/Resty

/**
 * Get the string associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return A string value.
 * @throws JSONException
 *           If there is no value for the index.
 */
public String getString(int index) throws JSONException {
  return get(index).toString();
}
origin: beders/Resty

/**
 * Get the long value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number.
 */
public long getLong(int index) throws JSONException {
  Object o = get(index);
  return o instanceof Number ? ((Number) o).longValue() : (long) getDouble(index);
}
origin: beders/Resty

/**
 * Get the JSONArray associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return A JSONArray value.
 * @throws JSONException
 *           If there is no value for the index. or if the value is not a
 *           JSONArray
 */
public JSONArray getJSONArray(int index) throws JSONException {
  Object o = get(index);
  if (o instanceof JSONArray) {
    return (JSONArray) o;
  }
  throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
}
origin: us.monoid.web/resty

/**
 * Get the int value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number. if the value cannot be converted to a number.
 */
public int getInt(int index) throws JSONException {
  Object o = get(index);
  return o instanceof Number ? ((Number) o).intValue() : (int) getDouble(index);
}
origin: beders/Resty

/**
 * Get the JSONObject associated with an index.
 * 
 * @param index
 *          subscript
 * @return A JSONObject value.
 * @throws JSONException
 *           If there is no value for the index or if the value is not a
 *           JSONObject
 */
public JSONObject getJSONObject(int index) throws JSONException {
  Object o = get(index);
  if (o instanceof JSONObject) {
    return (JSONObject) o;
  }
  throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
}
origin: us.monoid.web/resty

/**
 * Get the long value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number.
 */
public long getLong(int index) throws JSONException {
  Object o = get(index);
  return o instanceof Number ? ((Number) o).longValue() : (long) getDouble(index);
}
origin: beders/Resty

/**
 * Get the boolean value associated with an index. The string values "true"
 * and "false" are converted to boolean.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The truth.
 * @throws JSONException
 *           If there is no value for the index or if the value is not
 *           convertable to boolean.
 */
public boolean getBoolean(int index) throws JSONException {
  Object o = get(index);
  if (o.equals(Boolean.FALSE) || (o instanceof String && ((String) o).equalsIgnoreCase("false"))) {
    return false;
  } else if (o.equals(Boolean.TRUE)
      || (o instanceof String && ((String) o).equalsIgnoreCase("true"))) {
    return true;
  }
  throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
}
origin: us.monoid.web/resty

/**
 * Get the JSONArray associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return A JSONArray value.
 * @throws JSONException
 *           If there is no value for the index. or if the value is not a
 *           JSONArray
 */
public JSONArray getJSONArray(int index) throws JSONException {
  Object o = get(index);
  if (o instanceof JSONArray) {
    return (JSONArray) o;
  }
  throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
}
origin: us.monoid.web/resty

/**
 * Get the JSONObject associated with an index.
 * 
 * @param index
 *          subscript
 * @return A JSONObject value.
 * @throws JSONException
 *           If there is no value for the index or if the value is not a
 *           JSONObject
 */
public JSONObject getJSONObject(int index) throws JSONException {
  Object o = get(index);
  if (o instanceof JSONObject) {
    return (JSONObject) o;
  }
  throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
}
origin: beders/Resty

/**
 * Get the double value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number.
 */
public double getDouble(int index) throws JSONException {
  Object o = get(index);
  try {
    return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String) o)
        .doubleValue();
  } catch (Exception e) {
    throw new JSONException("JSONArray[" + index + "] is not a number.");
  }
}
origin: us.monoid.web/resty

/**
 * Get the double value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The value.
 * @throws JSONException
 *           If the key is not found or if the value cannot be converted to a
 *           number.
 */
public double getDouble(int index) throws JSONException {
  Object o = get(index);
  try {
    return o instanceof Number ? ((Number) o).doubleValue() : Double.valueOf((String) o)
        .doubleValue();
  } catch (Exception e) {
    throw new JSONException("JSONArray[" + index + "] is not a number.");
  }
}
origin: us.monoid.web/resty

/**
 * Get the boolean value associated with an index. The string values "true"
 * and "false" are converted to boolean.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return The truth.
 * @throws JSONException
 *           If there is no value for the index or if the value is not
 *           convertable to boolean.
 */
public boolean getBoolean(int index) throws JSONException {
  Object o = get(index);
  if (o.equals(Boolean.FALSE) || (o instanceof String && ((String) o).equalsIgnoreCase("false"))) {
    return false;
  } else if (o.equals(Boolean.TRUE)
      || (o instanceof String && ((String) o).equalsIgnoreCase("true"))) {
    return true;
  }
  throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
}
origin: us.monoid.web/resty

if (o instanceof JSONArray) {
 JSONArray array = JSONArray.class.cast(o);
 return array.get(index);
 } else {
 return null;
    Object item = array.get(i);
    boolean test = at(0).test(item);
        if (test) {
         result = item; // evaluation can continue on this item
                                break;
          if (obj.has(this.value.toString()))
origin: beders/Resty

if (o instanceof JSONArray) {
 JSONArray array = JSONArray.class.cast(o);
 return array.get(index);
 } else {
 return null;
    Object item = array.get(i);
    boolean test = at(0).test(item);
        if (test) {
         result = item; // evaluation can continue on this item
                                break;
          if (obj.has(this.value.toString()))
origin: beders/Resty

len = ja.length();
for (i = 0; i < len; i += 1) {
  e = ja.get(i);
  if (e != null) {
    if (e instanceof String) {
origin: org.integratedmodelling/klab-common

@Override
public List<IMetadata> search(String query, String authorityId) {
  ArrayList<IMetadata> ret = new ArrayList<IMetadata>();
  try {
    JSONResource res = new Resty().json(getSearchURL(query));
    JSONArray ares = res.array();
    // JSONArray ares = (JSONArray) res.get("results");
    for (int i = 0; i < ares.length(); i++) {
      JSONObject ores = (JSONObject) ares.get(i);
      if (ores != null) {
        Object rank = ores.get("rank");
        if (!rankOK(rank))
          continue;
        Metadata md = new Metadata();
        md.put("ID", ores.get("speciesKey"));
        md.put("Label", ores.get("canonicalName"));
        ret.add(md);
      }
    }
  } catch (Exception e) {
  }
  return ret;
}
origin: org.integratedmodelling/klab-engine

/**
 * TODO:
 * 
 * 1. use specific authority 2. use Java clients from GBIF 3. provide paging
 * 
 * @param query
 * @return
 */
public List<IMetadata> searchGBIF(String query) {
  ArrayList<IMetadata> ret = new ArrayList<>();
  try {
    JSONResource res = new Resty().json(getSearchURL(query));
    JSONArray ares = res.array();
    // JSONArray ares = (JSONArray) res.get("results");
    for (int i = 0; i < ares.length(); i++) {
      JSONObject ores = (JSONObject) ares.get(i);
      if (ores != null) {
        Object rank = ores.get("rank");
        if (!rankOK(rank))
          continue;
        Metadata md = new Metadata();
        md.put("ID", ores.get("speciesKey"));
        md.put("Label", ores.get("canonicalName"));
        ret.add(md);
      }
    }
  } catch (Exception e) {
  }
  return ret;
}
us.monoid.jsonJSONArrayget

Javadoc

Get the object value associated with an index.

Popular methods of JSONArray

  • length
    Get the number of elements in the JSONArray, included nulls.
  • getJSONObject
    Get the JSONObject associated with an index.
  • getString
    Get the string associated with an index.
  • toString
    Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data structu
  • <init>
    Construct a JSONArray from a JSONTokener.
  • getBoolean
    Get the boolean value associated with an index. The string values "true" and "false" are converted t
  • getDouble
    Get the double value associated with an index.
  • getInt
    Get the int value associated with an index.
  • getLong
    Get the long value associated with an index.
  • join
    Make a string from the contents of this JSONArray. Theseparator string is inserted between each elem
  • opt
    Get the optional object value associated with an index.
  • optBoolean
    Get the optional boolean value associated with an index. It returns the defaultValue if there is no
  • opt,
  • optBoolean,
  • optDouble,
  • optInt,
  • optJSONObject,
  • optLong,
  • optString,
  • put,
  • toJSONObject

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JPanel (javax.swing)
  • JTextField (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now