-
Notifications
You must be signed in to change notification settings - Fork 0
JTokenExtensionsGet
Extension class helpers for getting safely information from JTokens.
Null may be passed as the JToken and it will return the default. this allows token["propertyname"].Str() 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 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 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
Static parse of string. See JToken.Parse
public static QuickJSON.JToken JSONParse(this string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
text System.String
flags ParseOptions
Static parse of string for a JArray. See JArray.Parse
public static QuickJSON.JArray JSONParseArray(this string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
text System.String
flags ParseOptions
Static parse of string for a JObject. See JObject.Parse
public static QuickJSON.JObject JSONParseObject(this string text, QuickJSON.JToken.ParseOptions flags=QuickJSON.JToken.ParseOptions.None);
text System.String
flags ParseOptions
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
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
Clone object and remove all names starting with prefix
public static QuickJSON.JObject RemoveObjectFieldsKeyPrefix(this QuickJSON.JToken jo, string prefix);
jo JToken
prefix System.String
Clone a JObject and replace the fields in a JObject with different names given a pattern
public static QuickJSON.JObject RenameObjectFields(this QuickJSON.JToken jobject, string pattern, string replace, bool startswith=false);
jobject JToken
JSON Object
pattern System.String
Property name pattern to search for. Properties with this name or starting with this pattern name are altered
replace System.String
Replace the part of the name found using pattern with this. The rest of the name is kept
startswith System.Boolean
If false, replace any part of the name which has pattern in it with replace string.
If true, only replace names which start with pattern with replace string
JObject
Return a new JObject with these new names.
Clone object and remove all underscores
public static QuickJSON.JObject RenameObjectFieldsUnderscores(this QuickJSON.JToken jo);
jo 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
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