-
Notifications
You must be signed in to change notification settings - Fork 0
JArray
JSON Array object, holding a ordered list of JTokens
public class JArray : QuickJSON.JToken
Inheritance System.Object 🡒 JToken 🡒 JArray
Create an empty JArray
public JArray();
Create a JArray with these items as its data
public JArray(params object[] data);
data
System.Object[]
List of data to store in JArray
Create an array with a single item
public JArray(QuickJSON.JToken othertoken);
othertoken
JToken
JToken to store in array
Create a JArray from items in an IEnumerable
public JArray(System.Collections.IEnumerable data);
data
System.Collections.IEnumerable
IEnumerable with data itema
Get number of JArray items
public override int Count { get; }
Access JToken by int indexer
Returns JToken found by indexer
public QuickJSON.JToken this[int element] { get; set; }
element
System.Int32
System.ArgumentOutOfRangeException
If indexer is out of range
Access JToken by int indexer
Returns JToken found by indexer, or null if not present, indexer out of range or indexer is not an int
public override QuickJSON.JToken this[object key] { get; set; }
key
System.Object
System.ArgumentOutOfRangeException
If indexer is out of range on set
System.InvalidCastException
If indexer is not of type int on set
Add type T to the end of the array. T must be convertable to a JToken - see JToken Implicit conversions
public override void Add<T>(T value);
value
T
Add a JToken to the end of the array
public override void Add(QuickJSON.JToken o);
o
JToken
Add a range of items of type T to the end of the array. T must be convertable to a JToken - see JToken Implicit conversions
public override void AddRange<T>(System.Collections.Generic.IEnumerable<T> values);
values
System.Collections.Generic.IEnumerable<T>
Add a range of JTokens to the end of the array
public override void AddRange(System.Collections.Generic.IEnumerable<QuickJSON.JToken> o);
o
System.Collections.Generic.IEnumerable<JToken>
Convert the JTokens in the array to bool and return a list of bools.
Both true/false bool array and integer arrays (0=false, otherwise true) are acceptable
public System.Collections.Generic.List<bool> Bool();
System.Collections.Generic.List<System.Boolean>
System.InvalidCastException
If any items are not numbers or true or false
Clear the array
public override void Clear();
Convert the JTokens in the array to DateTime and return a list of DateTimes.
public System.Collections.Generic.List<System.DateTime> DateTime();
System.Collections.Generic.List<System.DateTime>
System.InvalidCastException
If any items are not DateTimes
Convert the JTokens in the array to doubles and return a list of doubles.
public System.Collections.Generic.List<double> Double();
System.Collections.Generic.List<System.Double>
System.InvalidCastException
If any items are not numbers
Find a JToken in the array according the the predicate and convert the value to type T. Return null if not found. If found, type must convert
public T Find<T>(System.Predicate<QuickJSON.JToken> predicate);
T
Type to convert the value to
predicate
System.Predicate<JToken>
System.InvalidOperationException
If JToken is not compatible with conversion.
Find a token in the array according the the predicate. Return null if not found
public QuickJSON.JToken Find(System.Predicate<QuickJSON.JToken> predicate);
predicate
System.Predicate<JToken>
Get the first JToken
public override QuickJSON.JToken First();
System.ArgumentOutOfRangeException
If no items are present
Get the first JToken or null if no elements are in the list
public override QuickJSON.JToken FirstOrDefault();
Convert the JTokens in the array to floats and return a list of floats.
public System.Collections.Generic.List<float> Float();
System.Collections.Generic.List<System.Single>
System.InvalidCastException
If any items are not numbers
Index of JToken
public int IndexOf(QuickJSON.JToken tk);
tk
JToken
Convert the JTokens in the array to int and return a list of ints. Truncation of value may occur.
public System.Collections.Generic.List<int> Int();
System.Collections.Generic.List<System.Int32>
System.InvalidCastException
If any items are not numbers
Get the last JToken
public override QuickJSON.JToken Last();
System.ArgumentOutOfRangeException
If no items are present
Get the last JToken or null if no elements are in the list
public override QuickJSON.JToken LastOrDefault();
Convert the JTokens in the array to longs and return a list of longs. Truncation of value may occur.
public System.Collections.Generic.List<long> Long();
System.Collections.Generic.List<System.Int64>
System.InvalidCastException
If any items are not numbers
Parse the JSON string presuming it will return an JArray
public static QuickJSON.JArray Parse(string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
text
System.String
Text to parse
flags
ParseOptions
Parsing flags, default None
JArray
JArray or null if parse fails or does not return a JArray
JsonException
Thrown on error if parse flags indicate exception required. Error will be in exception error value
Parse the JSON string presuming it will return an JArray
public static QuickJSON.JArray Parse(string text, out string error, QuickJSON.JToken.ParseOptions flags);
text
System.String
Text to parse
error
System.String
Null if no error, else error string
flags
ParseOptions
Parsing flags
JArray
JArray or null if parse fails or does not return a JArray
JsonException
Thrown on error if parse flags indicate exception required. Error will be in exception Error value
Parse the JSON string presuming it will return an JArray
Parsing flags are set to AllowTrailingCommas | CheckEOL | ThrowOnError
public static QuickJSON.JArray ParseThrowCommaEOL(string text);
text
System.String
Text to parse
JArray
JArray
JsonException
Thrown on error. Error will be in exception Error value
Remove JToken at index
public void RemoveAt(int index);
index
System.Int32
System.ArgumentOutOfRangeException
If index is out of range
public void RemoveRange(int index, int count);
index
System.Int32
count
System.Int32
System.ArgumentOutOfRangeException
If index is out of range
Convert the JTokens in the array to strings and return a list of strings.
Any non strings are inserted into the list as null
public System.Collections.Generic.List<string> String();
System.Collections.Generic.List<System.String>
Get a JToken at this index.
public bool TryGetValue(int index, out QuickJSON.JToken token);
index
System.Int32
Index of item
token
JToken
Where to store the found JToken
System.Boolean
If index out of range, return false (null in token), else return true (token has found item)