JTokenExtensionsGet - robbyxp1/QuickJSON GitHub Wiki
Extension class helpers for converting a JToken safely to a c# class.
Null may be passed as the JToken and it will return the default given in the converter
ie. token["propertyname"].Str("default") works safely even if propertyname does not exist.
public static class JTokenExtensionsGetInheritance System.Object 🡒 JTokenExtensionsGet
Convert token to JArray
public static QuickJSON.JArray Array(this QuickJSON.JToken token);
token JToken
Return a Big Integer. Return def if token is not present, not a number or null
public static System.Numerics.BigInteger BigInteger(this QuickJSON.JToken token, System.Numerics.BigInteger def);
token JToken
def System.Numerics.BigInteger
Return a Big Integer. Return null if token is not present, not a number or null
public static System.Nullable<System.Numerics.BigInteger> BigIntegerNull(this QuickJSON.JToken token);
token JToken
System.Nullable<System.Numerics.BigInteger>
Return a bool. Return def if token is not present, not a number or null
public static bool Bool(this QuickJSON.JToken token, bool def=false);
token JToken
def System.Boolean
Return an integer. Return null if token is not present, not a number or null
public static System.Nullable<bool> BoolNull(this QuickJSON.JToken token);
token JToken
System.Nullable<System.Boolean>
Return a DateTime with the parse of the string JToken.
public static System.DateTime DateTime(this QuickJSON.JToken token, System.DateTime def, System.Globalization.CultureInfo cultureinfo, System.Globalization.DateTimeStyles datetimestyle=System.Globalization.DateTimeStyles.AdjustToUniversal|System.Globalization.DateTimeStyles.AssumeUniversal);
token JToken
Token to convert. Must be a string. May be null.
def System.DateTime
Default time if conversion fails
cultureinfo System.Globalization.CultureInfo
Culture
datetimestyle System.Globalization.DateTimeStyles
Convert style
System.DateTime
DateTime
Return a nullable DateTime with the parse of the string JToken.
public static System.Nullable<System.DateTime> DateTime(this QuickJSON.JToken token, System.Globalization.CultureInfo cultureinfo, System.Globalization.DateTimeStyles datetimestyle=System.Globalization.DateTimeStyles.AdjustToUniversal|System.Globalization.DateTimeStyles.AssumeUniversal);
token JToken
Token to convert. Must be a string. May be null.
cultureinfo System.Globalization.CultureInfo
Culture
datetimestyle System.Globalization.DateTimeStyles
Convert style
System.Nullable<System.DateTime>
DateTime, or null if can't convert
Return a DateTime presuming UTC with the parse of the string JToken.
public static System.DateTime DateTimeUTC(this QuickJSON.JToken token);
token JToken
Token to convert. Must be a string. May be null.
System.DateTime
DateTime with Kind=UTC, or DateTime.MinValue (with Kind=UTC) if conversion fails
Return a DateTime presuming UTC with the parse of the string JToken.
public static System.DateTime DateTimeUTC(this QuickJSON.JToken token, System.DateTime def);
token JToken
Token to convert. Must be a string. May be null.
def System.DateTime
Default time if conversion fails. Converted to UTC
System.DateTime
DateTime with Kind=UTC, or def (with Kind=UTC) if conversion fails
Return a double. Return def if token is not present, not a number or null
public static double Double(this QuickJSON.JToken token, double def=0.0);
token JToken
def System.Double
Return a float with scaling. Return def if token is not present, not a number or null.
public static double Double(this QuickJSON.JToken token, double scale, double def);
token JToken
scale System.Double
def System.Double
Return a double. Return null if token is not present, not a number or null
public static System.Nullable<double> DoubleNull(this QuickJSON.JToken token);
token JToken
System.Nullable<System.Double>
Return a double with scaling. Return null if token is not present, not a number or null
public static System.Nullable<double> DoubleNull(this QuickJSON.JToken token, double scale);
token JToken
scale System.Double
System.Nullable<System.Double>
Return the enumeration of T from a JToken Long representation of the value of the enumeration. Return def if token is not present, null or not a long
public static T Enum<T>(this QuickJSON.JToken token, T def);
token JToken
def T
Convert a string token to an enumeration of type T. Return def if conversion fails
public static T Enumeration<T>(this QuickJSON.JToken token, T def, System.Func<string,string> preprocess=null);
token JToken
Token to convert. Must be a string. May be null.
def T
Default enumeration value
preprocess System.Func<System.String,System.String>
Function to call to preprocess the string before conversion. May be null
T
Enumeration, or def if converstion fails.
Return the enumeration of T from a JToken string representation of the value of the enumeration. Return def if token is not present, null or not a string.
public static T EnumStr<T>(this QuickJSON.JToken token, T def, bool ignorecase=true)
where T : struct;
token JToken
def T
ignorecase System.Boolean
Return a float. Return def if token is not present, not a number or null
public static float Float(this QuickJSON.JToken token, float def=0f);
token JToken
def System.Single
Return a float with scaling. Return def if token is not present, not a number or null.
public static float Float(this QuickJSON.JToken token, float scale, float def);
token JToken
scale System.Single
def System.Single
Return a float. Return null if token is not present, not a number or null
public static System.Nullable<float> FloatNull(this QuickJSON.JToken token);
token JToken
System.Nullable<System.Single>
Return a float with scale. Return null if token is not present, not a number or null
public static System.Nullable<float> FloatNull(this QuickJSON.JToken token, float scale);
token JToken
scale System.Single
System.Nullable<System.Single>
Index into JObject or JArray safely
public static QuickJSON.JToken I(this QuickJSON.JToken token, object id);
token JToken
Return an integer. Return def if token is not present, not a number or null
public static int Int(this QuickJSON.JToken token, int def=0);
token JToken
def System.Int32
Return an integer. Return null if token is not present, not a number or null
public static System.Nullable<int> IntNull(this QuickJSON.JToken token);
token JToken
Is token null or JToken Null
public static bool IsNull(this QuickJSON.JToken token);
token JToken
Return a long. Return def if token is not present, not a number or null
public static long Long(this QuickJSON.JToken token, long def=0L);
token JToken
def System.Int64
Return a long. Return null if token is not present, not a number or null
public static System.Nullable<long> LongNull(this QuickJSON.JToken token);
token JToken
Return a string looking for this list of property names. Return def if not found or not string
This one you must supply def but you can use the params array syntax with
public static string MultiStr(this QuickJSON.JObject token, string def, params string[] propertynameslist);
token JObject
def System.String
propertynameslist System.String[]
Return a string looking for this list of property names. Return def if not found or not string
public static string MultiStr(this QuickJSON.JObject token, string[] propertynameslist, string def="");
token JObject
propertynameslist System.String[]
def System.String
Convert token to JObject
public static QuickJSON.JObject Object(this QuickJSON.JToken token);
token JToken
Return a string from the token. Return def if null or not a string
public static string Str(this QuickJSON.JToken token, string def="");
token JToken
def System.String
Return a string from the token. Return null if not string
public static string StrNull(this QuickJSON.JToken token);
token JToken
Try and get a bool
public static bool TryGetBool(this QuickJSON.JToken token, out bool value);
token JToken
token
value System.Boolean
bool return
System.Boolean
true if token is not null and is an value which can convert to an bool
Try and get an double
public static bool TryGetDouble(this QuickJSON.JToken token, out double value);
token JToken
token
value System.Double
double return
System.Boolean
true if token is not null and is an value which can convert to an double
Try and get a float
public static bool TryGetFloat(this QuickJSON.JToken token, out float value);
token JToken
token
value System.Single
float return
System.Boolean
true if token is not null and is an value which can convert to an float
Try and get an integer
public static bool TryGetInt(this QuickJSON.JToken token, out int value);
token JToken
token
value System.Int32
integer return
System.Boolean
true if token is not null and is an value which can convert to an integer
Try and get an integer
public static bool TryGetLong(this QuickJSON.JToken token, out long value);
token JToken
token
value System.Int64
integer return
System.Boolean
true if token is not null and is an value which can convert to an integer
Try and get an integer
public static bool TryGetUInt(this QuickJSON.JToken token, out uint value);
token JToken
token
value System.UInt32
integer return
System.Boolean
true if token is not null and is an value which can convert to an integer
Try and get an integer
public static bool TryGetULong(this QuickJSON.JToken token, out ulong value);
token JToken
token
value System.UInt64
integer return
System.Boolean
true if token is not null and is an value which can convert to an integer
Return an unsigned integer. Return def if token is not present, not a number or null
public static uint UInt(this QuickJSON.JToken token, uint def=0u);
token JToken
def System.UInt32
Return an unsigned integer. Return null if token is not present, not a number or null
public static System.Nullable<uint> UIntNull(this QuickJSON.JToken token);
token JToken
System.Nullable<System.UInt32>
Return an unsigned long. Return def if token is not present, not a number or null
public static ulong ULong(this QuickJSON.JToken token, ulong def=0uL);
token JToken
def System.UInt64
Return an unsigned long. Return null if token is not present, not a number or null
public static System.Nullable<ulong> ULongNull(this QuickJSON.JToken token);
token JToken