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

How to use
JsonArray
in
org.hjson

Best Java code snippets using org.hjson.JsonArray (Showing top 20 results out of 315)

origin: org.hjson/hjson

/**
 * Returns an unmodifiable wrapper for the specified JsonArray. This method allows to provide
 * read-only access to a JsonArray.
 * <p>
 * The returned JsonArray is backed by the given array and reflects subsequent changes. Attempts
 * to modify the returned JsonArray result in an <code>UnsupportedOperationException</code>.
 * </p>
 *
 * @param array
 *          the JsonArray for which an unmodifiable JsonArray is to be returned
 * @return an unmodifiable view of the specified JsonArray
 */
public static JsonArray unmodifiableArray(JsonArray array) {
 return new JsonArray(array, true);
}
origin: hjson/hjson-java

/**
 * Appends the JSON representation of the specified <code>double</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(double value) {
 values.add(valueOf(value));
 return this;
}
origin: TridentSDK/TridentSDK

public JsonObject asJson() {
  JsonObject json = new JsonObject();
  json.add("max", maxPlayers);
  json.add("online", onlinePlayers);
  JsonArray sampleArray = new JsonArray();
  for (ServerPingResponseSample sample : samples) {
    if (sample != null) {
      sampleArray.add(sample.asJson());
    }
  }
  json.add("sample", sampleArray);
  return json;
}
origin: org.hjson/hjson

case ARRAY:
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (!noIndent) { if (n>0) nl(tw, level); else tw.write(separator); }
 tw.write('[');
 for (int i=0; i<n; i++) {
  nl(tw, level+1);
  save(arr.get(i), tw, level+1, "", true);
origin: hjson/hjson-java

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 do {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
 } while (readIf(','));
 if (!readIf(']')) {
  throw expected("',' or ']'");
 }
 return array;
}
origin: org.hjson/hjson

case ARRAY:
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (n>0) nl(tw, level);
 tw.write('[');
 for (int i=0; i<n; i++) {
  if (following) tw.write(",");
  JsonValue v=arr.get(i);
  JsonType vType=v.getType();
  if (vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) nl(tw, level+1);
origin: org.hjson/hjson

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 do {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
 } while (readIf(','));
 if (!readIf(']')) {
  throw expected("',' or ']'");
 }
 return array;
}
origin: hjson/hjson-java

case ARRAY:
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (n>0) nl(tw, level);
 tw.write('[');
 for (int i=0; i<n; i++) {
  if (following) tw.write(",");
  JsonValue v=arr.get(i);
  JsonType vType=v.getType();
  if (vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) nl(tw, level+1);
origin: hjson/hjson-java

/**
 * Appends the JSON representation of the specified <code>boolean</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(boolean value) {
 values.add(valueOf(value));
 return this;
}
origin: hjson/hjson-java

/**
 * Returns an unmodifiable wrapper for the specified JsonArray. This method allows to provide
 * read-only access to a JsonArray.
 * <p>
 * The returned JsonArray is backed by the given array and reflects subsequent changes. Attempts
 * to modify the returned JsonArray result in an <code>UnsupportedOperationException</code>.
 * </p>
 *
 * @param array
 *          the JsonArray for which an unmodifiable JsonArray is to be returned
 * @return an unmodifiable view of the specified JsonArray
 */
public static JsonArray unmodifiableArray(JsonArray array) {
 return new JsonArray(array, true);
}
origin: org.hjson/hjson

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 while (true) {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
  if (readIf(',')) skipWhiteSpace(); // , is optional
  if (readIf(']')) break;
  else if (isEndOfText()) throw error("End of input while parsing an array (did you forget a closing ']'?)");
 }
 return array;
}
origin: hjson/hjson-java

case ARRAY:
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (!noIndent) { if (n>0) nl(tw, level); else tw.write(separator); }
 tw.write('[');
 for (int i=0; i<n; i++) {
  nl(tw, level+1);
  save(arr.get(i), tw, level+1, "", true);
origin: org.hjson/hjson

/**
 * Appends the JSON representation of the specified <code>int</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(int value) {
 values.add(valueOf(value));
 return this;
}
origin: TridentSDK/TridentSDK

if (translate != null) {
  json.add("translate", translate);
  JsonArray array = new JsonArray();
  this.with.forEach(e -> array.add(e.stripColor()));
  json.add("with", array);
  JsonArray extraArray = new JsonArray();
  extra.forEach(e -> extraArray.add(e.stripColor()));
  json.add("extra", extraArray);
origin: TridentSDK/TridentSDK

if (with != null) {
  JsonArray array = with.asArray();
  for (int i = 0, j = array.size(); i < j; i++) {
    JsonValue el = array.get(i);
    if (el.isString() || el.isNumber() || el.isBoolean())
      cc.addWith(el.asString());
if (extra != null) {
  JsonArray array = extra.asArray();
  for (int i = 0, j = array.size(); i < j; i++) {
    JsonValue el = array.get(i);
    if (el.isString() || el.isNumber() || el.isBoolean())
      cc.addExtra(el.asString());
origin: org.hjson/hjson

/**
 * Appends the JSON representation of the specified <code>boolean</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(boolean value) {
 values.add(valueOf(value));
 return this;
}
origin: hjson/hjson-java

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 while (true) {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
  if (readIf(',')) skipWhiteSpace(); // , is optional
  if (readIf(']')) break;
  else if (isEndOfText()) throw error("End of input while parsing an array (did you forget a closing ']'?)");
 }
 return array;
}
origin: org.hjson/hjson

/**
 * Appends the JSON representation of the specified <code>float</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(float value) {
 values.add(valueOf(value));
 return this;
}
origin: TridentSDK/TridentSDK

if (translate != null) {
  json.add("translate", translate);
  JsonArray array = new JsonArray();
  this.with.forEach(e -> array.add(e.asJson()));
  json.add("with", array);
  JsonArray extraArray = new JsonArray();
  extra.forEach(e -> extraArray.add(e.asJson()));
  json.add("extra", extraArray);
origin: org.hjson/hjson

/**
 * Appends the JSON representation of the specified <code>long</code> value to the end of this
 * array.
 *
 * @param value
 *          the value to add to the array
 * @return the array itself, to enable method chaining
 */
public JsonArray add(long value) {
 values.add(valueOf(value));
 return this;
}
org.hjsonJsonArray

Javadoc

Represents a JSON array, an ordered collection of JSON values.

Elements can be added using the add(...) methods which accept instances of JsonValue, strings, primitive numbers, and boolean values. To replace an element of an array, use the set(int, ...) methods.

Elements can be accessed by their index using #get(int). This class also supports iterating over the elements in document order using an #iterator() or an enhanced for loop:

 
for (JsonValue value : jsonArray) { 
... 
} 

An equivalent List can be obtained from the method #values().

Note that this class is not thread-safe. If multiple threads access a JsonArray instance concurrently, while at least one of these threads modifies the contents of this array, access to the instance must be synchronized externally. Failure to do so may lead to an inconsistent state.

This class is not supposed to be extended by clients.

Most used methods

  • <init>
  • add
    Appends the JSON representation of the specified boolean value to the end of this array.
  • get
    Returns the value of the element at the specified position in this array.
  • size
    Returns the number of elements in this array.
  • valueOf

Popular in Java

  • Parsing JSON documents to java classes using gson
  • findViewById (Activity)
  • putExtra (Intent)
  • getApplicationContext (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JTable (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top plugins for Android Studio
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