Class JsonArray

java.lang.Object
com.chilkatsoft.chilkat2.ChilkatObject
com.chilkatsoft.chilkat2.JsonArray
All Implemented Interfaces:
AutoCloseable

public class JsonArray extends ChilkatObject
<section class="jsonarray-summary">

Read, modify, search, and emit ordered JSON arrays.

Chilkat.JsonArray is the JSON array companion to Chilkat.JsonObject. It represents an ordered list of JSON values and provides index-based methods for reading, inserting, replacing, deleting, swapping, searching, and emitting array data. It supports scalar values, nested objects, nested arrays, date/time parsing, exact numeric string handling, compact or pretty output, and search helpers for arrays of strings or arrays of objects.

Ordered JSON values

Work with JSON arrays as ordered lists containing strings, numbers, booleans, nulls, objects, arrays, and mixed value types.

Index-based access

Retrieve, insert, replace, delete, or swap values by array index when processing JSON list data.

Nested objects and arrays

Access child JsonObject and JsonArray values to navigate and modify deeper JSON structures.

Search helpers

Search arrays of strings or arrays of objects to locate matching values without manually scanning every element.

Date and numeric handling

Parse date/time values and preserve exact numeric strings when JSON data contains values that must not be rounded or reformatted.

Emit JSON output

Produce compact or pretty JSON output after array data has been loaded, edited, searched, or built programmatically.

Common pattern: Use JsonObject to navigate named members and JSON paths, then use JsonArray to iterate or modify ordered lists found within the object tree. Retrieve nested objects or arrays as needed, update values by index, and emit the final JSON in compact or pretty form.

For an extended overview, see JsonArray Class Overview.

</section>

Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when done; an unclosed instance is freed when it becomes unreachable.

See Also:
Online reference
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new JsonArray object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addArrayAt​(int index)
    Inserts a new, empty JSON array at zero-based position index.
    void
    addArrayAt2​(int index, JsonArray jarr)
    Inserts a new, empty JSON array at zero-based position index and updates jarr to reference the newly inserted array.
    void
    addBoolAt​(int index, boolean value)
    Inserts a new JSON boolean value at zero-based position index.
    void
    addIntAt​(int index, int value)
    Inserts a new JSON integer value at zero-based position index.
    void
    addNullAt​(int index)
    Inserts a JSON null value at zero-based position index.
    void
    addNumberAt​(int index, String numericStr)
    Inserts a JSON number at zero-based position index.
    void
    addObjectAt​(int index)
    Inserts a new, empty JSON object at zero-based position index.
    void
    addObjectAt2​(int index, JsonObject json)
    Inserts a new, empty JSON object at zero-based position index and updates json to reference the newly inserted object.
    void
    addObjectCopyAt​(int index, JsonObject jsonObj)
    Inserts an independent copy of jsonObj at zero-based position index.
    void
    addStringAt​(int index, String value)
    Inserts a new JSON string value at zero-based position index.
    void
    addUIntAt​(int index, long value)
    Inserts a new JSON unsigned integer value at zero-based position index.
    void
    Appends copies of all values from jarr to the end of this array, preserving their order.
    arrayAt​(int index)
    Returns the nested JSON array stored at zero-based position index.
    void
    arrayAt2​(int index, JsonArray jarr)
    Updates jarr so that it references the nested JSON array stored at zero-based position index.
    boolean
    boolAt​(int index)
    Returns the boolean value stored at zero-based position index.
    void
    Removes all values from the array, leaving an empty JSON array ([]).
    void
    dateAt​(int index, DateTime dt)
    Parses the date/time value at zero-based position index and loads the result into dt.
    void
    deleteAt​(int index)
    Deletes the value at zero-based position index.
    void
    dtAt​(int index, boolean bLocal, DtObj dt)
    Parses the date/time value at zero-based position index and loads the result into dt.
    Serializes this JSON array and returns the resulting JSON text.
    void
    Serializes this JSON array into the supplied StringBuilder.
    int
    findObject​(String name, String value, boolean caseSensitive)
    Searches array elements that are JSON objects and returns the zero-based index of the first object whose direct member name has a value matching value.
    int
    findString​(String value, boolean caseSensitive)
    Searches for the first string array element matching value and returns its zero-based index, or -1 if no match is found.
    boolean
    Controls whether emitted JSON is compact or pretty-formatted.
    boolean
    Controls line endings when pretty-formatted JSON is emitted.
    int
    Specifies the zero-based array index at which FindString and FindObject begin searching.
    int
    Returns the number of values currently contained in the JSON array.
    int
    intAt​(int index)
    Returns the integer value stored at zero-based position index.
    boolean
    isNullAt​(int index)
    Returns true if the value at zero-based position index is the JSON value null; otherwise returns false.
    void
    load​(String jsonArray)
    Parses the JSON array text in jsonArray and loads it into this object.
    void
    Parses the JSON array contained in sb and loads it into this object.
    objectAt​(int index)
    Returns the JSON object stored at zero-based position index.
    void
    objectAt2​(int index, JsonObject jsonObj)
    Updates jsonObj so that it references the JSON object stored at zero-based position index.
    void
    setBoolAt​(int index, boolean value)
    Replaces the value at zero-based position index with the specified JSON boolean value.
    void
    setEmitCompact​(boolean value)
    Sets the EmitCompact property; see getEmitCompact().
    void
    setEmitCrlf​(boolean value)
    Sets the EmitCrlf property; see getEmitCrlf().
    void
    setFindStartIndex​(int value)
    Sets the FindStartIndex property; see getFindStartIndex().
    void
    setIntAt​(int index, int value)
    Replaces the value at zero-based position index with the specified JSON integer value.
    void
    setNullAt​(int index)
    Replaces the value at zero-based position index with the JSON value null.
    void
    setNumberAt​(int index, String value)
    Replaces the value at zero-based position index with a JSON number.
    void
    setStringAt​(int index, String value)
    Replaces the value at zero-based position index with the specified JSON string value.
    void
    setUIntAt​(int index, long value)
    Replaces the value at zero-based position index with the specified JSON unsigned integer value.
    stringAt​(int index)
    Returns the string value stored at zero-based position index.
    void
    swap​(int index1, int index2)
    Exchanges the values at zero-based positions index1 and index2.
    int
    typeAt​(int index)
    Returns an integer identifying the JSON type of the value at zero-based position index.
    long
    uIntAt​(int index)
    Returns the unsigned integer value stored at zero-based position index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JsonArray

      public JsonArray()
      Creates a new JsonArray object.
  • Method Details

    • getEmitCompact

      public boolean getEmitCompact()
      Controls whether emitted JSON is compact or pretty-formatted. If true, output contains no unnecessary whitespace and is emitted on a single line. If false, indentation and line breaks are added for readability. The default is true.
      Returns:
      the value of the EmitCompact property
    • setEmitCompact

      public void setEmitCompact​(boolean value)
      Sets the EmitCompact property; see getEmitCompact().
      Parameters:
      value - the new value
    • getEmitCrlf

      public boolean getEmitCrlf()
      Controls line endings when pretty-formatted JSON is emitted. If true, line breaks use CRLF ( ); if false, they use LF ( ). The default is true.

      Applies only to pretty output: When EmitCompact is true, the JSON is emitted on one line and this setting has no effect.

      Returns:
      the value of the EmitCrlf property
    • setEmitCrlf

      public void setEmitCrlf​(boolean value)
      Sets the EmitCrlf property; see getEmitCrlf().
      Parameters:
      value - the new value
    • getFindStartIndex

      public int getFindStartIndex()
      Specifies the zero-based array index at which FindString and FindObject begin searching. The default value is 0.

      Iterating matches: After finding a match at index n, set this property to n + 1 before the next search to continue with later elements.

      Returns:
      the value of the FindStartIndex property
    • setFindStartIndex

      public void setFindStartIndex​(int value)
      Sets the FindStartIndex property; see getFindStartIndex().
      Parameters:
      value - the new value
    • getSize

      public int getSize()
      Returns the number of values currently contained in the JSON array. Array indexes therefore range from 0 through Size - 1.
      Returns:
      the value of the Size property (read-only)
    • addArrayAt

      public void addArrayAt​(int index)
      Inserts a new, empty JSON array at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addArrayAt2

      public void addArrayAt2​(int index, JsonArray jarr)
      Inserts a new, empty JSON array at zero-based position index and updates jarr to reference the newly inserted array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Immediate editing: Because jarr references the inserted array, it can be populated directly without a separate ArrayAt lookup.

      Parameters:
      index - the index argument
      jarr - the jarr argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addBoolAt

      public void addBoolAt​(int index, boolean value)
      Inserts a new JSON boolean value at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      value - the value argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addIntAt

      public void addIntAt​(int index, int value)
      Inserts a new JSON integer value at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      value - the value argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addNullAt

      public void addNullAt​(int index)
      Inserts a JSON null value at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addNumberAt

      public void addNumberAt​(int index, String numericStr)
      Inserts a JSON number at zero-based position index. The numericStr argument supplies the exact JSON numeric text to store. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Exact numeric text: Use this method when lexical form or precision matters, for example 12345678901234567890, 1.2500, or scientific notation. The supplied text must be valid JSON number syntax; JSON does not permit NaN or infinity.

      Parameters:
      index - the index argument
      numericStr - the numericStr argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addObjectAt

      public void addObjectAt​(int index)
      Inserts a new, empty JSON object at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addObjectAt2

      public void addObjectAt2​(int index, JsonObject json)
      Inserts a new, empty JSON object at zero-based position index and updates json to reference the newly inserted object.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Immediate editing: Because json references the inserted object, it can be populated directly without a separate ObjectAt lookup.

      Parameters:
      index - the index argument
      json - the json argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addObjectCopyAt

      public void addObjectCopyAt​(int index, JsonObject jsonObj)
      Inserts an independent copy of jsonObj at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Copy semantics: The inserted object is copied rather than referenced. Later changes to the source jsonObj do not serve as edits to the inserted array value.

      Parameters:
      index - the index argument
      jsonObj - the jsonObj argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addStringAt

      public void addStringAt​(int index, String value)
      Inserts a new JSON string value at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      value - the value argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addUIntAt

      public void addUIntAt​(int index, long value)
      Inserts a new JSON unsigned integer value at zero-based position index. Existing elements at that position and after it are shifted one position toward the end of the array.

      0 Insert as the first array element.

      -1 Append as the last array element.

      n Insert at zero-based position n.

      Insert vs. replace: The Add*At methods insert a new array element. Use the corresponding Set*At method when replacing an existing element.

      Parameters:
      index - the index argument
      value - the value argument (0 .. 4294967295)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • appendArrayItems

      public void appendArrayItems​(JsonArray jarr)
      Appends copies of all values from jarr to the end of this array, preserving their order.

      Source is unchanged: The source array is not emptied or moved. This method is useful for concatenating JSON arrays, including arrays belonging to different JSON documents.

      Parameters:
      jarr - the jarr argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • arrayAt

      public JsonArray arrayAt​(int index)
      Returns the nested JSON array stored at zero-based position index.

      Reference, not copy: The returned JsonArray refers to the existing nested array in the same JSON document. Changes made through the returned object modify that nested array.Type requirement: The value at index must be an array. Use TypeAt when the value type is not already known.

      Parameters:
      index - the index argument
      Returns:
      a new JsonArray owned by the caller (never null); close it when done
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • arrayAt2

      public void arrayAt2​(int index, JsonArray jarr)
      Updates jarr so that it references the nested JSON array stored at zero-based position index.

      Reference, not copy: Changes made through jarr modify the existing nested array in the same JSON document.

      Parameters:
      index - the index argument
      jarr - the jarr argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • boolAt

      public boolean boolAt​(int index)
      Returns the boolean value stored at zero-based position index.

      Type-aware access: Use TypeAt when the JSON type at index is not already known.

      Parameters:
      index - the index argument
      Returns:
      the result; this method never throws ChilkatException
    • clear

      public void clear()
      Removes all values from the array, leaving an empty JSON array ([]).
    • dateAt

      public void dateAt​(int index, DateTime dt)
      Parses the date/time value at zero-based position index and loads the result into dt. Recognized forms include ISO 8601 timestamps (for example, 2009-11-04T19:55:41Z), RFC 822-style date/time strings, and Unix timestamp integers.

      JSON has no native date type: Dates are application conventions represented as strings or numbers. These methods recognize common representations and convert them to Chilkat date/time objects.

      Parameters:
      index - the index argument
      dt - the dt argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • deleteAt

      public void deleteAt​(int index)
      Deletes the value at zero-based position index. Elements following the deleted value shift down by one position.
      Parameters:
      index - the index argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • dtAt

      public void dtAt​(int index, boolean bLocal, DtObj dt)
      Parses the date/time value at zero-based position index and loads the result into dt. If bLocal is true, the populated fields represent local time; if false, they represent UTC/GMT. Recognized forms include ISO 8601 timestamps, RFC 822-style date/time strings, and Unix timestamp integers.

      JSON has no native date type: Dates are application conventions represented as strings or numbers. These methods recognize common representations and convert them to Chilkat date/time objects.

      Parameters:
      index - the index argument
      bLocal - the bLocal argument
      dt - the dt argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • emit

      public String emit()
      Serializes this JSON array and returns the resulting JSON text.

      Formatting: Set EmitCompact to choose compact versus pretty output. When pretty output is enabled, EmitCrlf selects CRLF or LF line endings.

      Returns:
      the result (never null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • emitSb

      public void emitSb​(StringBuilder sb)
      Serializes this JSON array into the supplied StringBuilder.

      Formatting: Set EmitCompact to choose compact versus pretty output. When pretty output is enabled, EmitCrlf selects CRLF or LF line endings.Large JSON: Using a StringBuilder can avoid returning a very large JSON document as a language-native string before passing it to another Chilkat method or writing it to a file.

      Parameters:
      sb - the sb argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • findObject

      public int findObject​(String name, String value, boolean caseSensitive)
      Searches array elements that are JSON objects and returns the zero-based index of the first object whose direct member name has a value matching value. Returns -1 if no match is found. The value pattern may contain *, which matches zero or more characters. Set caseSensitive to control whether letter case must match.

      Member name, not JSON path: name identifies a direct member of each object being tested; it is not a JSON path.Search start: Searching begins at FindStartIndex, whose default is 0. To continue searching after a match, set FindStartIndex to the previous returned index plus 1.

      Parameters:
      name - the name argument (not null)
      value - the value argument (not null)
      caseSensitive - the caseSensitive argument
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)
    • findString

      public int findString​(String value, boolean caseSensitive)
      Searches for the first string array element matching value and returns its zero-based index, or -1 if no match is found. The pattern may contain *, which matches zero or more characters. Set caseSensitive to control whether letter case must match.

      Search start: Searching begins at FindStartIndex, whose default is 0. To continue searching after a match, set FindStartIndex to the previous returned index plus 1.

      Parameters:
      value - the value argument (not null)
      caseSensitive - the caseSensitive argument
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)
    • intAt

      public int intAt​(int index)
      Returns the integer value stored at zero-based position index.

      Type-aware access: Use TypeAt when the JSON type at index is not already known.

      Parameters:
      index - the index argument
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)
    • isNullAt

      public boolean isNullAt​(int index)
      Returns true if the value at zero-based position index is the JSON value null; otherwise returns false.

      JSON null: null is a distinct JSON value. It is not the same as an empty string, zero, false, an empty object, or an empty array.

      Parameters:
      index - the index argument
      Returns:
      the result; this method never throws ChilkatException
    • load

      public void load​(String jsonArray)
      Parses the JSON array text in jsonArray and loads it into this object. The input must represent a JSON array, beginning with [ and ending with ].

      Important — loading detaches the array: Calling this method makes the JsonArray its own independent JSON document. If the object previously referenced an array nested inside another JSON document, that relationship is discarded. For this reason, call Load/LoadSb on a new JsonArray instance.

      Parameters:
      jsonArray - the jsonArray argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • loadSb

      public void loadSb​(StringBuilder sb)
      Parses the JSON array contained in sb and loads it into this object. The input must represent a JSON array, beginning with [ and ending with ].

      Important — loading detaches the array: Calling this method makes the JsonArray its own independent JSON document. If the object previously referenced an array nested inside another JSON document, that relationship is discarded. For this reason, call Load/LoadSb on a new JsonArray instance.

      Parameters:
      sb - the sb argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • objectAt

      public JsonObject objectAt​(int index)
      Returns the JSON object stored at zero-based position index.

      Reference, not copy: The returned JsonObject refers to the existing object in the same JSON document. Changes made through the returned object modify that nested object.Type requirement: The value at index must be an object. Use TypeAt when the value type is not already known.

      Parameters:
      index - the index argument
      Returns:
      a new JsonObject owned by the caller (never null); close it when done
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • objectAt2

      public void objectAt2​(int index, JsonObject jsonObj)
      Updates jsonObj so that it references the JSON object stored at zero-based position index.

      Reference, not copy: Changes made through jsonObj modify the existing object in the same JSON document.

      Parameters:
      index - the index argument
      jsonObj - the jsonObj argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setBoolAt

      public void setBoolAt​(int index, boolean value)
      Replaces the value at zero-based position index with the specified JSON boolean value. The array length and the positions of other elements are unchanged.
      Parameters:
      index - the index argument
      value - the value argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setIntAt

      public void setIntAt​(int index, int value)
      Replaces the value at zero-based position index with the specified JSON integer value. The array length and the positions of other elements are unchanged.
      Parameters:
      index - the index argument
      value - the value argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setNullAt

      public void setNullAt​(int index)
      Replaces the value at zero-based position index with the JSON value null. The array length and the positions of other elements are unchanged.
      Parameters:
      index - the index argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setNumberAt

      public void setNumberAt​(int index, String value)
      Replaces the value at zero-based position index with a JSON number. The value argument supplies the exact JSON numeric text to store.

      Exact numeric text: Use this method when lexical form or precision matters. The supplied text must be valid JSON number syntax; JSON does not permit NaN or infinity.

      Parameters:
      index - the index argument
      value - the value argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setStringAt

      public void setStringAt​(int index, String value)
      Replaces the value at zero-based position index with the specified JSON string value. The array length and the positions of other elements are unchanged.
      Parameters:
      index - the index argument
      value - the value argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setUIntAt

      public void setUIntAt​(int index, long value)
      Replaces the value at zero-based position index with the specified JSON unsigned integer value. The array length and the positions of other elements are unchanged.
      Parameters:
      index - the index argument
      value - the value argument (0 .. 4294967295)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • stringAt

      public String stringAt​(int index)
      Returns the string value stored at zero-based position index.

      Type-aware access: Use TypeAt when the JSON type at index is not already known.

      Parameters:
      index - the index argument
      Returns:
      the result (never null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • swap

      public void swap​(int index1, int index2)
      Exchanges the values at zero-based positions index1 and index2. The array length does not change.
      Parameters:
      index1 - the index1 argument
      index2 - the index2 argument
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • typeAt

      public int typeAt​(int index)
      Returns an integer identifying the JSON type of the value at zero-based position index. Returns -1 if no value exists at that index.

      1 string

      2 number

      3 object

      4 array

      5 boolean

      6 null

      Why use TypeAt: JSON arrays may contain mixed types. Checking the type first avoids choosing a type-specific accessor such as ObjectAt, ArrayAt, or IntAt for the wrong kind of value.

      Parameters:
      index - the index argument
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)
    • uIntAt

      public long uIntAt​(int index)
      Returns the unsigned integer value stored at zero-based position index.

      Type-aware access: Use TypeAt when the JSON type at index is not already known.

      Parameters:
      index - the index argument
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)