-
Notifications
You must be signed in to change notification settings - Fork 0
JTokenExtensions
Class which extends QuickJSON with the ability to create c# objects from JTokens
public static class JTokenExtensions
Inheritance System.Object 🡒 JTokenExtensions
Clear ToObject convert cache
public static void ClearToObjectCache();
JTokenExtensions.ToObject<T>(JToken, bool, Func<Type,string,object>, string, Func<Type,object,object>) Method
Convert the JToken tree to an object of type T. Protected from all exception sources
public static T ToObject<T>(this QuickJSON.JToken token, bool ignoretypeerrors=false, System.Func<System.Type,string,object> process=null, string setname=null, System.Func<System.Type,object,object> customformat=null);
token
JToken
JToken to convert from
ignoretypeerrors
System.Boolean
Ignore any errors in type between the JToken type and the member type.
process
System.Func<System.Type,System.String,System.Object>
For enums and datetime, and if set, process and return enum or DateTime
setname
System.String
Define set of JSON attributes to apply, null for default
customformat
System.Func<System.Type,System.Object,System.Object>
Class members convert to object using this function if marked with [JsonCustomFormat]
T
New object T containing fields filled by JToken, or default(T) on error.
JTokenExtensions.ToObject(JToken, Type, bool, BindingFlags, object, Func<Type,string,object>, string, Func<Type,object,object>) Method
Convert the JToken tree to an object of type. This member will except.
public static object ToObject(this QuickJSON.JToken token, System.Type converttype, bool ignoretypeerrors, System.Reflection.BindingFlags membersearchflags=System.Reflection.BindingFlags.Instance|System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.Public, object initialobject=null, System.Func<System.Type,string,object> process=null, string setname=null, System.Func<System.Type,object,object> customformat=null);
token
JToken
JToken to convert from
converttype
System.Type
Type to convert to
ignoretypeerrors
System.Boolean
Ignore any errors in type between the JToken type and the member type.
membersearchflags
System.Reflection.BindingFlags
Member search flags, to select what types of members are serialised.
Use the default plus DeclaredOnly for only members of the top class only
initialobject
System.Object
If null, object is newed. If given, start from this object. Will except if it and the converttype is not compatible.
process
System.Func<System.Type,System.String,System.Object>
For enums and datetime, and if set, process and return enum or DateTime
setname
System.String
Define set of JSON attributes to apply, null for default
customformat
System.Func<System.Type,System.Object,System.Object>
Class members convert to object using this function if marked with [JsonCustomFormat]
System.Object
Object containing fields filled by JToken, or a object of ToObjectError on named error, or null if no tokens
System.Exception
Generic exception
System.InvalidCastException
If a type failure occurs. Other excepections could also occur.
JTokenExtensions.ToObjectProtected(JToken, Type, bool, BindingFlags, object, Func<Type,string,object>, string, Func<Type,object,object>) Method
Convert the JToken tree to an object of type. Protected from all exception sources
public static object ToObjectProtected(this QuickJSON.JToken token, System.Type converttype, bool ignoretypeerrors, System.Reflection.BindingFlags membersearchflags=System.Reflection.BindingFlags.Instance|System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.Public, object initialobject=null, System.Func<System.Type,string,object> process=null, string setname=null, System.Func<System.Type,object,object> customformat=null);
token
JToken
JToken to convert from
converttype
System.Type
Type to convert to
ignoretypeerrors
System.Boolean
Ignore any errors in type between the JToken type and the member type.
membersearchflags
System.Reflection.BindingFlags
Member search flags, to select what types of members are serialised
initialobject
System.Object
If null, object is newed. If given, start from this object. Will except if it and the converttype is not compatible.
process
System.Func<System.Type,System.String,System.Object>
For enums and datetime, and if set, process and return enum or DateTime.
setname
System.String
Define set of JSON attributes to apply, null for default
customformat
System.Func<System.Type,System.Object,System.Object>
Class members convert to object using this function if marked with [JsonCustomFormat]
System.Object
Object containing fields filled by JToken, or a object of ToObjectError on named error, or null if no tokens
Convert the JToken tree to an object of type T.
Type errors are not ignored
public static T ToObjectQ<T>(this QuickJSON.JToken token);
token
JToken
JToken to convert from
T
New object T containing fields filled by JToken, or default(T) on error
Classes | |
---|---|
JTokenExtensions.ToObjectError | Class to hold an conversion error |