Skip to content
robbyxp1 edited this page Feb 9, 2025 · 18 revisions

JToken Class

JToken is the base type of all JSON Tokens. JObject and JArray are derived from this
Provides Parsers and Decoders for all JSON properties

public class JToken :
System.Collections.Generic.IEnumerable<QuickJSON.JToken>,
System.Collections.IEnumerable

Inheritance System.Object 🡒 JToken

Derived
JArray
JObject

Implements System.Collections.Generic.IEnumerable<JToken>, System.Collections.IEnumerable


Constructors


JToken.JToken() Constructor

Construct a JSON Null token (default)

public JToken();


JToken.JToken(JToken) Constructor

Construct a copy of another JToken

public JToken(QuickJSON.JToken other);
Parameters

other JToken


JToken.JToken(TType, object, int) Constructor

Create a token

public JToken(QuickJSON.JToken.TType tokentype, object value=null, int level=0);
Parameters

tokentype TType
Token type to make

value System.Object
Optional, value of token

level System.Int32
Set the level of the token in the JSON heirarchy


Properties


JToken.Count Property

Get number of JArray or JObject items (of 0 for JToken)

public virtual int Count { get; }
Property Value

System.Int32


JToken.HasValue Property

Does the object have a Value. True for bool/string/number

public bool HasValue { get; }
Property Value

System.Boolean


JToken.IsArray Property

Is the token a JSON Array

public bool IsArray { get; }
Property Value

System.Boolean


JToken.IsBigInt Property

Is the token a BigInt

public bool IsBigInt { get; }
Property Value

System.Boolean


JToken.IsBool Property

Is the token a Boolean

public bool IsBool { get; }
Property Value

System.Boolean


JToken.IsDouble Property

Is the token a Real Number

public bool IsDouble { get; }
Property Value

System.Boolean


JToken.IsEndArray Property

Is the token a End Array marker

public bool IsEndArray { get; }
Property Value

System.Boolean


JToken.IsEndObject Property

Is the token a End Object marker

public bool IsEndObject { get; }
Property Value

System.Boolean


JToken.IsInError Property

Is the token an error token

public bool IsInError { get; }
Property Value

System.Boolean


JToken.IsInt Property

Is the token a Integer Number

public bool IsInt { get; }
Property Value

System.Boolean


JToken.IsLong Property

Is the token a Long

public bool IsLong { get; }
Property Value

System.Boolean


JToken.IsNull Property

Is the token a Null

public bool IsNull { get; }
Property Value

System.Boolean


JToken.IsNumber Property

Is the token a Real or Integer Number

public bool IsNumber { get; }
Property Value

System.Boolean


JToken.IsObject Property

Is the token a JSON Object

public bool IsObject { get; }
Property Value

System.Boolean


JToken.IsProperty Property

Is the token a property of an Object. Only set during Parse or ParseToken.
Compiler initialiser will not have this set

public bool IsProperty { get; }
Property Value

System.Boolean


JToken.IsString Property

Is the token a string

public bool IsString { get; }
Property Value

System.Boolean


JToken.IsULong Property

Is the token a Unsigned Long

public bool IsULong { get; }
Property Value

System.Boolean


JToken.Level Property

Heirachy level, 0 onwards. Set in Parse and ParseToken only

public int Level { get; set; }
Property Value

System.Int32


JToken.Name Property

Name of token found during parsing if its a property of an JSON Object, or Null if not a property.
Only set during Parse and ParseToken. Not set on an compiler initialisation.
On Parse, if the property name is empty it will be called !!!EmptyNameN!!! N is 0..
If it is a repeat of a previous name, it will be called name[N] where N = 1..
JObject [] must have unique names for all objects
On ParseToken, this will be the name in the text, irrespective or empty or repeat.

public string Name { get; set; }
Property Value

System.String


JToken.OriginalName Property

Normally null, set to the original name in Parse only if the name is empty or a repeat

public string OriginalName { get; set; }
Property Value

System.String


JToken.ParsedName Property

The parsed name, either Name or OriginalName (if the property name was empty or a repeat), set on Parse or ParseToken only

public string ParsedName { get; }
Property Value

System.String


JToken.this[object] Property

Access JToken in JArray or JObject by indexer. For JArray its an integer index (0+) and for JObject its the property string key name.
Returns JToken found by indexer, or null if noRobet present, indexer out of range (JArray) or indexer is not the right type

public virtual QuickJSON.JToken this[object key] { get; set; }
Parameters

key System.Object

Property Value

JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object

System.ArgumentOutOfRangeException
If indexer is out of range on set (JArray)

System.InvalidCastException
If indexer is not of right type for object on set


JToken.TokenType Property

The JToken type

public QuickJSON.JToken.TType TokenType { get; set; }
Property Value

TType


JToken.TraceOutput Property

Set to enable trace output on failures which are ordered to be masked during operation

public static bool TraceOutput { get; set; }
Property Value

System.Boolean


JToken.Value Property

Value of the token, if it has one

public object Value { get; set; }
Property Value

System.Object


Methods


JToken.Add<T>(string, T) Method

Add value of type T with this property name. Will overwrite any existing property. T must be convertable to a JToken - see JToken Implicit conversions

public virtual void Add<T>(string key, T value);
Type parameters

T

Parameters

key System.String

value T

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.Add<T>(T) Method

Add to a JArray a value of type T thru this class. T must be convertable to a JToken - see JToken Implicit conversions

public virtual void Add<T>(T value);
Type parameters

T

Parameters

value T

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.Add(JToken) Method

Add to a JArray a JToken thru this class

public virtual void Add(QuickJSON.JToken value);
Parameters

value JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.Add(string, JToken) Method

Add a JToken with this property name thru this class. Will overwrite any existing property

public virtual void Add(string key, QuickJSON.JToken value);
Parameters

key System.String

value JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.AddRange<T>(IEnumerable<T>) Method

Add a range of items of type T to a JArray thru this class. T must be convertable to a JToken - see JToken Implicit conversions

public virtual void AddRange<T>(System.Collections.Generic.IEnumerable<T> values);
Type parameters

T

Parameters

values System.Collections.Generic.IEnumerable<T>

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.AddRange(IEnumerable<JToken>) Method

Add a range of JTokens to a JArray thru this class.

public virtual void AddRange(System.Collections.Generic.IEnumerable<QuickJSON.JToken> o);
Parameters

o System.Collections.Generic.IEnumerable<JToken>

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.Clear() Method

Clear JArray or JObject of items

public virtual void Clear();
Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.ClearFromObjectCache() Method

Clear FromObject convert cache

public static void ClearFromObjectCache();


JToken.Clone() Method

Return a copy of this JToken

public QuickJSON.JToken Clone();
Returns

JToken


JToken.Contains(string) Method

Does the JObject contain property name

public virtual bool Contains(string name);
Parameters

name System.String

Returns

System.Boolean


JToken.CreateToken(object, bool) Method

Creata a token from an object
* Will convert null, string
* Will convert bool,byte,sbyte,decimal,double,float,int,uint,long,ulong,short,ushort, DateTime and their ? types as per the implicit rules
* Will convert a Enum type to a JSON string
* Will clone a JArray or JObject

public static QuickJSON.JToken CreateToken(object obj, bool except=true);
Parameters

obj System.Object
Object to make token from

except System.Boolean
True to except on error, else return null

Returns

JToken


JToken.DeepEquals(JToken) Method

Perform an equality test for all values in the JToken
* Doubles use an approximate equals dependent on size to find equality.
* Will compare all JToken Number types against all other JNumber types.
* JObject properties do not have to be in the same order in both tokens.
* Booleans will compare against either another boolean or an integer (!=0 is true)

public bool DeepEquals(QuickJSON.JToken other);
Parameters

other JToken
JToken to compare with

Returns

System.Boolean
True if all values are the same.


JToken.DeepEquals(JToken, JToken) Method

Static interface to Deep Equals

public static bool DeepEquals(QuickJSON.JToken left, QuickJSON.JToken right);
Parameters

left JToken

right JToken

Returns

System.Boolean


JToken.First() Method

Get the first JToken

public virtual QuickJSON.JToken First();
Returns

JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object

System.ArgumentOutOfRangeException
If no items are present


JToken.FirstOrDefault() Method

Get the first JToken or null if no elements are in the list

public virtual QuickJSON.JToken FirstOrDefault();
Returns

JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.FromObject(object) Method

Convert Object to JToken tree
Beware of using this except for the simpliest classes, use one below and control the ignored/max recursion

public static QuickJSON.JToken FromObject(object obj);
Parameters

obj System.Object
Object to convert from

Returns

JToken
JToken tree


JToken.FromObject(object, bool, Type[], int, BindingFlags, bool, string, Func<object,JToken>) Method

Convert Object to JToken tree

public static QuickJSON.JToken FromObject(object obj, bool ignoreunserialisable, System.Type[] ignored=null, int maxrecursiondepth=256, System.Reflection.BindingFlags membersearchflags=System.Reflection.BindingFlags.Instance|System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.Public, bool ignoreobjectpropertyifnull=false, string setname=null, System.Func<object,QuickJSON.JToken> customconvert=null);
Parameters

obj System.Object
Object to convert from

ignoreunserialisable System.Boolean
If true, do not stop if an unserialisable member is found. These are self referencing members which would cause an infinite loop

ignored System.Type[]
List of ignored types not to serialise, may be null

maxrecursiondepth System.Int32
Maximum depth to recurse through the objects heirarchy

membersearchflags System.Reflection.BindingFlags
Member search flags, to select what types of members are serialised

ignoreobjectpropertyifnull System.Boolean
acts as per JSONIgnoreIfNull and does not output JSON object property null

setname System.String
Define set of JSON attributes to apply, null for default

customconvert System.Func<System.Object,JToken>
Use this custom converter on class members when they are marked with [JsonCustomFormat]n

Returns

JToken
Null if can't convert (error detected) or JToken tree


JToken.FromObjectWithError(object, bool, Type[], int, BindingFlags, bool, string, Func<object,JToken>) Method

Convert Object to JToken tree

public static QuickJSON.JToken FromObjectWithError(object obj, bool ignoreunserialisable, System.Type[] ignored=null, int maxrecursiondepth=256, System.Reflection.BindingFlags membersearchflags=System.Reflection.BindingFlags.Instance|System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.Public, bool ignoreobjectpropertyifnull=false, string setname=null, System.Func<object,QuickJSON.JToken> customconvert=null);
Parameters

obj System.Object
Object to convert from

ignoreunserialisable System.Boolean
If true, do not stop if an unserialisable member is found. These are self referencing members which would cause an infinite loop

ignored System.Type[]
List of ignored types not to serialise, may be null

maxrecursiondepth System.Int32
Maximum depth to recurse through the objects heirarchy

membersearchflags System.Reflection.BindingFlags
Member search flags, to select what types of members are serialised

ignoreobjectpropertyifnull System.Boolean
acts as per JSONIgnoreIfNull and does not output JSON object property null

setname System.String
Define set of JSON attributes to apply, null for default

customconvert System.Func<System.Object,JToken>
Use this custom converter on class members when they are marked with [JsonCustomFormat]n

Returns

JToken
JToken error type if can't convert (check with IsInError, value has error reason) or JToken tree


JToken.GetEnumerator() Method

Get an Enumerator for the JToken

public System.Collections.Generic.IEnumerator<QuickJSON.JToken> GetEnumerator();
Returns

System.Collections.Generic.IEnumerator<JToken>

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object

Implements GetEnumerator(), GetEnumerator()


JToken.GetMemberAttributeSettings(Type, string, BindingFlags) Method

Get the list of included attributes to output using FromObject for a particular class, given setname and member search flags
Completely ignored objects are not included

public static System.Collections.Generic.Dictionary<string,QuickJSON.JToken.MemberAttributeSettings> GetMemberAttributeSettings(System.Type tt, string setname=null, System.Reflection.BindingFlags membersearchflags=System.Reflection.BindingFlags.Instance|System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.Public);
Parameters

tt System.Type
class type

setname System.String
name of set, or null

membersearchflags System.Reflection.BindingFlags
search flags to apply

Returns

System.Collections.Generic.Dictionary<System.String,MemberAttributeSettings>
Dictionary keyed by member name of all non ignored attributes


JToken.GetSchemaTypeName() Method

Return JSON Schema name of the object

public string GetSchemaTypeName();
Returns

System.String
Schema type name or null for not json type


JToken.GetToken(string) Method

Get the token at the end of the path using JSONPath format.
. [] format only. Do not include $ as we do not have an absolute path.
https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html

public QuickJSON.JToken GetToken(string path);
Parameters

path System.String
Path to the token

Returns

JToken


JToken.GetTokenSchemaPath(string) Method

Get the token at the end of the path using schema format
objectname/objectname only. Do not include #/ as we do not have an absolute path.

public QuickJSON.JToken GetTokenSchemaPath(string path);
Parameters

path System.String
Path to the token

Returns

JToken


JToken.IsKeyNameSynthetic(string) Method

If the parsed name is empty or a repeat, it will be given a synthetic name.

public static bool IsKeyNameSynthetic(string name);
Parameters

name System.String

Returns

System.Boolean


JToken.Last() Method

Get the last JToken

public virtual QuickJSON.JToken Last();
Returns

JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object

System.ArgumentOutOfRangeException
If no items are present


JToken.LastOrDefault() Method

Get the last JToken or null if no elements are in the list

public virtual QuickJSON.JToken LastOrDefault();
Returns

JToken

Exceptions

System.NotImplementedException
Thrown if used on an non indexed object


JToken.LoadTokens(IEnumerator<JToken>) Method

Read the token stream at the current heirarchy level into the current enumerator JToken

public static bool LoadTokens(System.Collections.Generic.IEnumerator<QuickJSON.JToken> enumerator);
Parameters

enumerator System.Collections.Generic.IEnumerator<JToken>
Current enumerator position. Will load the item at the enumerator will all fields found and then stop

Returns

System.Boolean
true if loaded correctly


JToken.Null() Method

Creates a Null JToken

public static QuickJSON.JToken Null();
Returns

JToken


JToken.Parse(IStringParserQuick, string, ParseOptions, char[], int) Method

Parse JSON text and produce a JToken tree. This is the lowest level parser allowing a buffer to be fed into it
Note any empty name properties will be names !!!EmptyNameN!!! to make them unique and searchable
Note any repeat name properties will be names !!!Repeat-Name[repeatnumber] make them unique and searchable

public static QuickJSON.JToken Parse(QuickJSON.Utils.IStringParserQuick parser, out string error, QuickJSON.JToken.ParseOptions flags, char[] textbuffer, int stackdepth);
Parameters

parser IStringParserQuick
A string parser based on IStringParserQuick

error System.String
Null on success, or error text

flags ParseOptions
Parser flags

textbuffer System.Char[]
Buffer to store JSON elements in

stackdepth System.Int32
Maximum depth of objects allowed in JSON

Returns

JToken
JToken tree or null on error

Exceptions

JsonException
On error, and flags indicate throw on error, exception is thrown with the exception holding the reason


JToken.Parse(IStringParserQuick, string, ParseOptions, int, int) Method

Parse JSON text and produce a JToken tree

public static QuickJSON.JToken Parse(QuickJSON.Utils.IStringParserQuick parser, out string error, QuickJSON.JToken.ParseOptions flags, int charbufsize, int stackdepth);
Parameters

parser IStringParserQuick
A string parser based on IStringParserQuick

error System.String
Null on success, or error text

flags ParseOptions
Parser flags

charbufsize System.Int32
Maximum length of a JSON element

stackdepth System.Int32
Maximum depth of objects allowed in JSON

Returns

JToken
JToken tree or null on error

Exceptions

JsonException
On error, and flags indicate throw on error, exception is thrown with the exception holding the reason


JToken.Parse(string, ParseOptions) Method

Parse JSON text and produce a JToken tree

public static QuickJSON.JToken Parse(string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
Parameters

text System.String
Text to parse

flags ParseOptions
Parser flags

Returns

JToken
Null on error, or JToken tree

Exceptions

JsonException
On error, and flags indicate throw on error, exception is thrown with the exception holding the reason


JToken.Parse(string, string, ParseOptions) Method

Parse JSON text and produce a JToken tree

public static QuickJSON.JToken Parse(string text, out string error, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
Parameters

text System.String
Text to parse

error System.String
Null on success, or error text

flags ParseOptions
Parser flags

Returns

JToken
JToken tree or null on error

Exceptions

JsonException
On error, and flags indicate throw on error, exception is thrown with the exception holding the reason


JToken.Parse(TextReader, string, ParseOptions, int, int) Method

Parse JSON text and produce a JToken tree

public static QuickJSON.JToken Parse(System.IO.TextReader trx, out string error, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None, int chunksize=16384, int charbufsize=16384);
Parameters

trx System.IO.TextReader
Text reader to read the text from

error System.String
Null on success, or error text

flags ParseOptions
Parser flags

chunksize System.Int32
Text reader chunk buffer size, bigger the better

charbufsize System.Int32
Maximum length of a JSON element

Returns

JToken
JToken tree or null on error

Exceptions

JsonException
On error, and flags indicate throw on error, exception is thrown with the exception holding the reason


JToken.ParseThrow(string, ParseOptions) Method

Parse JSON text and produce a JToken tree. Throw a exception on error

public static QuickJSON.JToken ParseThrow(string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
Parameters

text System.String
Text to parse

flags ParseOptions
Parser flags

Returns

JToken
JToken tree

Exceptions

JsonException
On error exception is thrown with the exception holding the reason


JToken.ParseThrowCommaEOL(string) Method

Parse JSON text and produce a JToken tree.
Parse flags are AllowTrailingCommas | CheckEOL | ThrowOnError

public static QuickJSON.JToken ParseThrowCommaEOL(string text);
Parameters

text System.String
Text to parse

Returns

JToken
JToken tree

Exceptions

JsonException
On error exception is thrown with the exception holding the reason


JToken.ParseToken(IStringParserQuick, ParseOptions, int) Method

Read a token string and return one by one the JTokens.
Will return JToken EndArray and JToken EndObject to indicate end of those objects

public static System.Collections.Generic.IEnumerable<QuickJSON.JToken> ParseToken(QuickJSON.Utils.IStringParserQuick parser, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None, int charbufsize=16384);
Parameters

parser IStringParserQuick
A string parser based on IStringParserQuick

flags ParseOptions
JSON Parser flags

charbufsize System.Int32
Maximum length of a JSON element

Returns

System.Collections.Generic.IEnumerable<JToken>
Next token, or Null at end of text

Exceptions

TokenException
Exception when token reader fails


JToken.ParseToken(TextReader, ParseOptions, int) Method

Read a token string and return one by one the JTokens.
Will return JToken EndArray and JToken EndObject to indicate end of those objects

public static System.Collections.Generic.IEnumerable<QuickJSON.JToken> ParseToken(System.IO.TextReader tr, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None, int charbufsize=16384);
Parameters

tr System.IO.TextReader
A text reader to get the text from

flags ParseOptions
JSON Parser flags

charbufsize System.Int32
Maximum length of a JSON element

Returns

System.Collections.Generic.IEnumerable<JToken>
Next token, or Null at end of text

Exceptions

TokenException
Exception when token reader fails


JToken.ToString() Method

Convert to string default settings

public override string ToString();
Returns

System.String
JSON string representation


JToken.ToString(bool, string) Method

Convert to string

public string ToString(bool verbose=false, string oapad="  ");
Parameters

verbose System.Boolean
If verbose, pad the structure out

oapad System.String
Pad before objects or arrays are outputted (only for verbose=true) mode

Returns

System.String
JSON string representation


JToken.ToString(JToken, string, string, string, bool, int) Method

Convert to string

public static string ToString(QuickJSON.JToken token, string prepad, string postpad, string oapad, bool stringliterals, int linelength=int.MaxValue);
Parameters

token JToken
Token to convert

prepad System.String
Pad before token is outputted

postpad System.String
Pad after token is outputted

oapad System.String
Pad before objects or arrays are outputted

stringliterals System.Boolean
true to output strings or keys without escaping or quoting

linelength System.Int32
introduce new line between entries when exceeded this length. If postpad = \r\n don't use

Returns

System.String
JSON string representation


JToken.ToString(string) Method

Convert to string with ability to control the array/output pad

public string ToString(string oapad);
Parameters

oapad System.String
Pad before objects or arrays are outputted

Returns

System.String
JSON string representation


JToken.ToString(string, string, string, bool, int) Method

Convert to string

public string ToString(string prepad, string postpad, string oapad, bool stringliterals, int linelength=int.MaxValue);
Parameters

prepad System.String
Pad before token is outputted

postpad System.String
Pad after token is outputted

oapad System.String
Pad before objects or arrays are outputted

stringliterals System.Boolean
true to output strings or keys without escaping or quoting

linelength System.Int32
introduce new line between entries when exceeded this length. If postpad = \r\n don't use

Returns

System.String
JSON string representation


JToken.ToStringBuilder(StringBuilder, JToken, string, string, string, bool) Method

Convert to string using string builder

public static void ToStringBuilder(System.Text.StringBuilder str, QuickJSON.JToken token, string prepad, string postpad, string oapad, bool stringliterals);
Parameters

str System.Text.StringBuilder
Stringbuilder to append to

token JToken
Token to convert

prepad System.String
Pad before token is outputted

postpad System.String
Pad after token is outputted

oapad System.String
Pad before objects or arrays are outputted

stringliterals System.Boolean
true to output strings and key names without escaping or quoting


JToken.ToStringBuilder(StringBuilder, JToken, string, string, string, bool, int, int) Method

Convert to string using string builder

public static void ToStringBuilder(System.Text.StringBuilder str, QuickJSON.JToken token, string prepad, string postpad, string oapad, bool stringliterals, ref int lastcr, int maxlinelength);
Parameters

str System.Text.StringBuilder
Stringbuilder to append to

token JToken
Token to convert

prepad System.String
Pad before token is outputted

postpad System.String
Pad after token is outputted

oapad System.String
Pad before objects or arrays are outputted

stringliterals System.Boolean
true to output strings and key names without escaping or quoting

lastcr System.Int32
where last cr is. set to 0 to start

maxlinelength System.Int32
introduce new line between entries when exceeded this length


JToken.ToStringLiteral() Method

Convert to string with strings themselves being unquoted or escaped.
Useful for data extraction purposes

public string ToStringLiteral();
Returns

System.String
JSON string representation


JToken.ValueEquals(object) Method

Is this token equal to another tokens value. Only for object types of string, int, uint, long, ulong, bool

public bool ValueEquals(object value);
Parameters

value System.Object

Returns

System.Boolean


JToken.ValueEquals(JToken) Method

Is this token equal to another tokens. For types incl double

public bool ValueEquals(QuickJSON.JToken other);
Parameters

other JToken

Returns

System.Boolean

Operators


JToken.explicit operator bool(JToken) Operator

Explicit conversion of a JSON Token Boolean or Long to a bool.

public static bool explicit operator bool(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Boolean

Exceptions

System.InvalidOperationException
If JToken is not of the right type


JToken.explicit operator double(JToken) Operator

Explicit conversion of a JSON Token Unsigned Long, Long, BigInt or Double to a double.

public static double explicit operator double(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Double

Exceptions

System.InvalidOperationException
If JToken is not of the right type


JToken.explicit operator float(JToken) Operator

Explicit conversion of a JSON Token Unsigned Long, Long, BigInt or Double to an float.

public static float explicit operator float(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Single

Exceptions

System.InvalidOperationException
If JToken is not of the right type


JToken.explicit operator int(JToken) Operator

Explicit conversion of a JSON Token Long or Double to an int.

public static int explicit operator int(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Int32

Exceptions

System.InvalidOperationException
If JToken is not a Long or Double


JToken.explicit operator long(JToken) Operator

Explicit conversion of a JSON Token Long or Double to a long.

public static long explicit operator long(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Int64

Exceptions

System.InvalidOperationException
If JToken is not a Long or Double


JToken.explicit operator string(JToken) Operator

Explicit conversion of a JSON Token Null or String to a string. Return null if JToken is not a Null or String

public static string explicit operator string(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.String


JToken.explicit operator DateTime(JToken) Operator

Explicit conversion of a JSON Token String to a date, assuming UTC. Return MinValue if JToken is not of the right type or date conversion fails

public static System.DateTime explicit operator DateTime(QuickJSON.JToken t);
Parameters

t JToken

Returns

System.DateTime


JToken.explicit operator Nullable<bool>(JToken) Operator

Explicit conversion of a JSON Token Boolean or Long to a bool.
Both true/false and integers (0=false, otherwise true) are acceptable
Return null if JToken is not of the right type

public static System.Nullable<bool> explicit operator Nullable<bool>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.Boolean>


JToken.explicit operator Nullable<double>(JToken) Operator

Explicit conversion of a JSON Token Long, Unsigned Long, BigInt or Double to a double?. Return null if JToken is not of the right type

public static System.Nullable<double> explicit operator Nullable<double>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.Double>


JToken.explicit operator Nullable<float>(JToken) Operator

Explicit conversion of a JSON Token Long, Unsigned Long, BigInt or Double to a float?. Return null if JToken is not of the right type

public static System.Nullable<float> explicit operator Nullable<float>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.Single>


JToken.explicit operator Nullable<int>(JToken) Operator

Explicit conversion of a JSON Token Long or Double to an int?. Return null if JToken is not a Long or Double

public static System.Nullable<int> explicit operator Nullable<int>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.Int32>


JToken.explicit operator Nullable<long>(JToken) Operator

Explicit conversion of a JSON Token Long or Double to a long?. Return null if JToken is not a Long or Double

public static System.Nullable<long> explicit operator Nullable<long>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.Int64>


JToken.explicit operator Nullable<uint>(JToken) Operator

Explicit conversion of a JSON Token Long or Double to an uint?. Return null if JToken is not a Long or Double or negative

public static System.Nullable<uint> explicit operator Nullable<uint>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.UInt32>


JToken.explicit operator Nullable<ulong>(JToken) Operator

Explicit conversion of a JSON Token Unsigned Long, Long or Double to an unsigned long?. Return null if JToken is not a Long or Double or negative

public static System.Nullable<ulong> explicit operator Nullable<ulong>(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.Nullable<System.UInt64>


JToken.explicit operator uint(JToken) Operator

Explicit conversion of a JSON Token Long or Double to an unsigned int.

public static uint explicit operator uint(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.UInt32

Exceptions

System.InvalidOperationException
If JToken is not a Long or Double or negative.


JToken.explicit operator ulong(JToken) Operator

Explicit conversion of a JSON Token Unsigned Long, Long or Double to an unsigned long.

public static ulong explicit operator ulong(QuickJSON.JToken tk);
Parameters

tk JToken

Returns

System.UInt64

Exceptions

System.InvalidOperationException
If JToken is not of the right type or negative


JToken.implicit operator JToken(bool) Operator

Implicit conversion of a bool to a JSON token of the type Bool

public static QuickJSON.JToken implicit operator JToken(bool v);
Parameters

v System.Boolean

Returns

JToken


JToken.implicit operator JToken(byte) Operator

Implicit conversion of a byte to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(byte v);
Parameters

v System.Byte

Returns

JToken


JToken.implicit operator JToken(char) Operator

Implicit conversion of a character to a JSON token of the type String

public static QuickJSON.JToken implicit operator JToken(char v);
Parameters

v System.Char

Returns

JToken


JToken.implicit operator JToken(decimal) Operator

Implicit conversion of a decimal to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(decimal v);
Parameters

v System.Decimal

Returns

JToken


JToken.implicit operator JToken(double) Operator

Implicit conversion of a double to a JSON token of the type Double

public static QuickJSON.JToken implicit operator JToken(double v);
Parameters

v System.Double

Returns

JToken


JToken.implicit operator JToken(float) Operator

Implicit conversion of a float to a JSON token of the type Double

public static QuickJSON.JToken implicit operator JToken(float v);
Parameters

v System.Single

Returns

JToken


JToken.implicit operator JToken(int) Operator

Implicit conversion of a int to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(int v);
Parameters

v System.Int32

Returns

JToken


JToken.implicit operator JToken(long) Operator

Implicit conversion of a long to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(long v);
Parameters

v System.Int64

Returns

JToken


JToken.implicit operator JToken(sbyte) Operator

Implicit conversion of a sbyte to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(sbyte v);
Parameters

v System.SByte

Returns

JToken


JToken.implicit operator JToken(short) Operator

Implicit conversion of a short to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(short v);
Parameters

v System.Int16

Returns

JToken


JToken.implicit operator JToken(string) Operator

Implicit conversion of a string to a JSON token of the type String

public static QuickJSON.JToken implicit operator JToken(string v);
Parameters

v System.String

Returns

JToken


JToken.implicit operator JToken(DateTime) Operator

Implicit conversion of a DateTime to a JSON token of the type String.
In the zulu format yyyy-mm-ddThh-mm-ssZ or yyyy-mm-ddThh-mm-ss.fffZ

public static QuickJSON.JToken implicit operator JToken(System.DateTime v);
Parameters

v System.DateTime

Returns

JToken


JToken.implicit operator JToken(uint) Operator

Implicit conversion of a unsigned int to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(uint v);
Parameters

v System.UInt32

Returns

JToken


JToken.implicit operator JToken(ulong) Operator

Implicit conversion of a ulong to a JSON token of the type Unsigned Long

public static QuickJSON.JToken implicit operator JToken(ulong v);
Parameters

v System.UInt64

Returns

JToken


JToken.implicit operator JToken(ushort) Operator

Implicit conversion of a unsigned short to a JSON token of the type Long

public static QuickJSON.JToken implicit operator JToken(ushort v);
Parameters

v System.UInt16

Returns

JToken

Explicit Interface Implementations


JToken.System.Collections.IEnumerable.GetEnumerator() Method

Get a IEnumerator for the JToken

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator();
Exceptions

System.NotImplementedException
Thrown if used on an non indexed object

Implements GetEnumerator()


Classes

Classes
JToken.JsonException Exception Class for JSON Parsers. Holds Error string
JToken.MemberAttributeSettings Holds the attribute settings found - used in FromObject
JToken.TokenException Exception when the token reader fails

Enums


JToken.ParseOptions Enum

Parse options for QuickJSON Parser

public enum JToken.ParseOptions
Fields

AllowTrailingCommas 1
Allow a extra trailing comma after the end of an object or array list

CheckEOL 2
Error if extra text is present beyond the end of the JSON Token stream

IgnoreBadArrayValue 16
Ignore a bad array value, the array entry will be replaced with a null. Try and resynchronise with the token stream

IgnoreBadObjectValue 8
Ignore a bad object value, and try and resynchronise with the token stream

None 0
Standard parse

ThrowOnError 4
Throw a JsonException if an error is encountered. If not, null will be returned


JToken.TType Enum

Token Type

public enum JToken.TType
Fields

Array 8
JSON Array

BigInt 6
JSON Number, BigInt

Boolean 1
JSON boolean value

Double 3
JSON Number, real

EndArray 10
For token reading only, an EndArray ']' token

EndObject 9
For token reading only, an EndObject '}' token

Error 11
In FromObject, an error has occurred. Value holds error string

Long 4
JSON Number, long (64 bits)

Null 0
JSON Null

Object 7
JSON Object

String 2
JSON string

ULong 5
JSON Number, unsigned long (64 bits)

Clone this wiki locally