Tabnine Logo
JSONArray.length
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: beders/Resty

/**
 * Get the optional object value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return An object value, or null if there is no object at that index.
 */
public Object opt(int index) {
  return (index < 0 || index >= length()) ? null : this.myArrayList.get(index);
}
origin: us.monoid.web/resty

/**
 * Get the optional object value associated with an index.
 * 
 * @param index
 *          The index must be between 0 and length() - 1.
 * @return An object value, or null if there is no object at that index.
 */
public Object opt(int index) {
  return (index < 0 || index >= length()) ? null : this.myArrayList.get(index);
}
origin: beders/Resty

/**
 * Make a string from the contents of this JSONArray. The
 * <code>separator</code> string is inserted between each element. Warning:
 * This method assumes that the data structure is acyclical.
 * 
 * @param separator
 *          A string that will be inserted between the elements.
 * @return a string.
 * @throws JSONException
 *           If the array contains an invalid number.
 */
public String join(String separator) throws JSONException {
  int len = length();
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < len; i += 1) {
    if (i > 0) {
      sb.append(separator);
    }
    sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
  }
  return sb.toString();
}
origin: us.monoid.web/resty

/**
 * Make a string from the contents of this JSONArray. The
 * <code>separator</code> string is inserted between each element. Warning:
 * This method assumes that the data structure is acyclical.
 * 
 * @param separator
 *          A string that will be inserted between the elements.
 * @return a string.
 * @throws JSONException
 *           If the array contains an invalid number.
 */
public String join(String separator) throws JSONException {
  int len = length();
  StringBuffer sb = new StringBuffer();
  for (int i = 0; i < len; i += 1) {
    if (i > 0) {
      sb.append(separator);
    }
    sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
  }
  return sb.toString();
}
origin: beders/Resty

for (int i = 0; i < ja.length(); i += 1) {
  if (i > 0) {
    sb.append(',');
origin: org.ihtsdo.otf.common/otf-common

private JSONObject getLatestClassificationObjectOnBranch(String branchPath) throws RestClientException {
  final String classificationsUrl = urlHelper.getClassificationsUrl(branchPath);
  try {
    final JSONArray items = getItems(classificationsUrl);
    if (items != null && items.length() > 0) {
      return items.getJSONObject(items.length() - 1);
    }
    return null;
  } catch (Exception e) {
    throw new RestClientException("Failed to retrieve list of classifications.", e);
  }
}
origin: beders/Resty

/**
 * Produce a JSONObject by combining a JSONArray of names with the values of
 * this JSONArray.
 * 
 * @param names
 *          A JSONArray containing a list of key strings. These will be paired
 *          with the values.
 * @return A JSONObject, or null if there are no names or if this JSONArray
 *         has no values.
 * @throws JSONException
 *           If any of the names are null.
 */
public JSONObject toJSONObject(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0 || length() == 0) {
    return null;
  }
  JSONObject jo = new JSONObject();
  for (int i = 0; i < names.length(); i += 1) {
    jo.put(names.getString(i), this.opt(i));
  }
  return jo;
}
origin: us.monoid.web/resty

/**
 * Produce a JSONObject by combining a JSONArray of names with the values of
 * this JSONArray.
 * 
 * @param names
 *          A JSONArray containing a list of key strings. These will be paired
 *          with the values.
 * @return A JSONObject, or null if there are no names or if this JSONArray
 *         has no values.
 * @throws JSONException
 *           If any of the names are null.
 */
public JSONObject toJSONObject(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0 || length() == 0) {
    return null;
  }
  JSONObject jo = new JSONObject();
  for (int i = 0; i < names.length(); i += 1) {
    jo.put(names.getString(i), this.opt(i));
  }
  return jo;
}
origin: beders/Resty

  /**
   * Produce a comma delimited text from a JSONArray of JSONObjects using
   * a provided list of names. The list of names is not included in the
   * output.
   * @param names A JSONArray of strings.
   * @param ja A JSONArray of JSONObjects.
   * @return A comma delimited text.
   * @throws JSONException
   */
  public static String toString(JSONArray names, JSONArray ja)
      throws JSONException {
    if (names == null || names.length() == 0) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ja.length(); i += 1) {
      JSONObject jo = ja.optJSONObject(i);
      if (jo != null) {
        sb.append(rowToString(jo.toJSONArray(names)));
      }
    }
    return sb.toString();
  }
}
origin: us.monoid.web/resty

  /**
   * Produce a comma delimited text from a JSONArray of JSONObjects using
   * a provided list of names. The list of names is not included in the
   * output.
   * @param names A JSONArray of strings.
   * @param ja A JSONArray of JSONObjects.
   * @return A comma delimited text.
   * @throws JSONException
   */
  public static String toString(JSONArray names, JSONArray ja)
      throws JSONException {
    if (names == null || names.length() == 0) {
      return null;
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ja.length(); i += 1) {
      JSONObject jo = ja.optJSONObject(i);
      if (jo != null) {
        sb.append(rowToString(jo.toJSONArray(names)));
      }
    }
    return sb.toString();
  }
}
origin: org.ihtsdo.otf.common/otf-common

public List<String> retrieveValidationStatuses(List<String> branchPaths) throws Exception {
  StringBuilder url = new StringBuilder(orchestrationUrl + VALIDATIONS_ENDPOINT + "/bulk/latest/statuses");
  url.append("?paths=");
  boolean first = true;
  for (String branchPath : branchPaths) {
    if (!first) {
      url.append(",");
    } else {
      first = false;
    }
    url.append(branchPath);
  }
  final JSONResource resource = getResource(url.toString());
  if (resource == null) {
    return null;
  }
  final JSONArray array = resource.array();
  List<String> statuses = new ArrayList<>();
  for (int a = 0; a < array.length(); a++) {
    final String string = array.getString(a);
    statuses.add(!string.equals("null") ? string : null);
  }
  return statuses;
}
origin: beders/Resty

/**
 * Produce a JSONArray containing the names of the elements of this
 * JSONObject.
 * 
 * @return A JSONArray containing the key strings, or null if the JSONObject
 *         is empty.
 */
public JSONArray names() {
  JSONArray ja = new JSONArray();
  Iterator<String> keys = keys();
  while (keys.hasNext()) {
    ja.put(keys.next());
  }
  return ja.length() == 0 ? null : ja;
}
origin: beders/Resty

/**
 * Produce a JSONArray of JSONObjects from a comma delimited text string
 * using a supplied JSONArray as the source of element names.
 * @param names A JSONArray of strings.
 * @param x A JSONTokener of the source text.
 * @return A JSONArray of JSONObjects.
 * @throws JSONException
 */
public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
    throws JSONException {
  if (names == null || names.length() == 0) {
    return null;
  }
  JSONArray ja = new JSONArray();
  for (;;) {
    JSONObject jo = rowToJSONObject(names, x);
    if (jo == null) {
      break;
    }
    ja.put(jo);
  }
  if (ja.length() == 0) {
    return null;
  }
  return ja;
}
origin: us.monoid.web/resty

/**
 * Produce a JSONArray containing the names of the elements of this
 * JSONObject.
 * 
 * @return A JSONArray containing the key strings, or null if the JSONObject
 *         is empty.
 */
public JSONArray names() {
  JSONArray ja = new JSONArray();
  Iterator<String> keys = keys();
  while (keys.hasNext()) {
    ja.put(keys.next());
  }
  return ja.length() == 0 ? null : ja;
}
origin: us.monoid.web/resty

/**
 * Produce a JSONArray of JSONObjects from a comma delimited text string
 * using a supplied JSONArray as the source of element names.
 * @param names A JSONArray of strings.
 * @param x A JSONTokener of the source text.
 * @return A JSONArray of JSONObjects.
 * @throws JSONException
 */
public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
    throws JSONException {
  if (names == null || names.length() == 0) {
    return null;
  }
  JSONArray ja = new JSONArray();
  for (;;) {
    JSONObject jo = rowToJSONObject(names, x);
    if (jo == null) {
      break;
    }
    ja.put(jo);
  }
  if (ja.length() == 0) {
    return null;
  }
  return ja;
}
origin: beders/Resty

/**
 * Produce a JSONArray containing the values of the members of this
 * JSONObject.
 * 
 * @param names
 *          A JSONArray containing a list of key strings. This determines the
 *          sequence of the values in the result.
 * @return A JSONArray of values.
 * @throws JSONException
 *           If any of the values are non-finite numbers.
 */
public JSONArray toJSONArray(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0) {
    return null;
  }
  JSONArray ja = new JSONArray();
  for (int i = 0; i < names.length(); i += 1) {
    ja.put(this.opt(names.getString(i)));
  }
  return ja;
}
origin: us.monoid.web/resty

/**
 * Produce a JSONArray containing the values of the members of this
 * JSONObject.
 * 
 * @param names
 *          A JSONArray containing a list of key strings. This determines the
 *          sequence of the values in the result.
 * @return A JSONArray of values.
 * @throws JSONException
 *           If any of the values are non-finite numbers.
 */
public JSONArray toJSONArray(JSONArray names) throws JSONException {
  if (names == null || names.length() == 0) {
    return null;
  }
  JSONArray ja = new JSONArray();
  for (int i = 0; i < names.length(); i += 1) {
    ja.put(this.opt(names.getString(i)));
  }
  return ja;
}
origin: jpasqua/TeslaClient

public List<Vehicle> queryVehicles() {
  List<Vehicle> list = new ArrayList<>(2);
  try {
    JSONResource r = api.json(apiEndpoint("vehicles"));
    JSONArray rawVehicleData = r.object().getJSONArray("response");
    int numVehicles = rawVehicleData.length();
    for (int i = 0; i < numVehicles; i++) {
      Vehicle vehicle = new Vehicle(this, rawVehicleData.getJSONObject(i));
      list.add(vehicle);
    }
  } catch (IOException | JSONException ex) {
    logger.warning("Problem fetching vehicle list: " + ex);
  }
  return list;
}
origin: us.monoid.web/resty

char c = x.next();
if (value == null || 
    (ja.length() == 0 && value.length() == 0 && c != ',')) {
  return null;
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;
}
us.monoid.jsonJSONArraylength

Javadoc

Get the number of elements in the JSONArray, included nulls.

Popular methods of JSONArray

  • get
    Get the object value associated with an index.
  • 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

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JPanel (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top plugins for WebStorm
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