Class JsonSerializerExt
Provides the means to merge JSON into an existing object, by reflection.
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class JsonSerializerExt
- Inheritance
-
JsonSerializerExt
- Inherited Members
Methods
PopulateObject(object, string, Type)
Sets an object's properties from the JSON's, as PopulateObject<T>(T, string) does.
public static void PopulateObject(object target, string jsonSource, Type type)
Parameters
targetobjectThe object.
jsonSourcestringThe JSON object.
typeTypeThe type whose properties are set.
Exceptions
- JsonException
The text is not JSON, or a value does not fit its property.
- InvalidOperationException
A JSON value is not of the kind the property needs.
- UriFormatException
A Uri property's text is not a URI.
PopulateObject<T>(T, string)
Sets an object's properties from the JSON's, by exact name: a value-type, string or Uri property, a JSON array or a null replaces the value; another JSON object merges into the property's current object, and a null property stays null. A name the type does not have is passed over.
public static void PopulateObject<T>(T target, string jsonSource) where T : class
Parameters
targetTThe object.
jsonSourcestringThe JSON object.
Type Parameters
TThe object's type, whose properties are set.
Exceptions
- JsonException
The text is not JSON, or a value does not fit its property.
- InvalidOperationException
A JSON value is not of the kind the property needs.
- UriFormatException
A Uri property's text is not a URI.