C# Класс Microsoft.WindowsAzure.MobileServices.JsonExtensions

Helpful extensions that make it easier to manipulate JSON values.
Nulls propagate through calls so for example, given a JSON object like { 'typeInfo': { 'bar' : 2 } }, you could just write obj.Get("typeInfo").Get("bar").AsInteger() to get the value 2. Given a JSON object like { 'baz': 2 }, you could write obj.Get("typeInfo").Get("bar").AsInteger() to get the value null.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Append ( this array, JToken value ) : Newtonsoft.Json.Linq.JArray

Add an element to a JSON array.

AsArray ( this value ) : Newtonsoft.Json.Linq.JArray

Convert a JSON value into an array, returning null if it's unable.

AsBool ( this value ) : bool?

Convert a JSON value into a bool, returning null if it's unable.

AsInteger ( this value ) : int?

Convert a JSON value into an int, returning null if it's unable.

AsNumber ( this value ) : double?

Convert a JSON value into a double, returning null if it's unable.

AsObject ( this value ) : Newtonsoft.Json.Linq.JObject

Convert a JSON value into an object, returning null if it's unable.

AsString ( this value ) : string

Convert a JSON value into a string, returning null if it's unable.

Get ( this value, string name ) : JToken

Gets a named value from an object.

GetPropertyValues ( this value ) : JToken>>.IEnumerable

Enumerate the member name/value pairs of a JSON object.

IsNull ( this value ) : bool

Determine if the value represents null.

Null ( ) : JToken

Get a null JSON value (that when serialized will stay null rather than not being written out).

Set ( this obj, string name, JToken value ) : JContainer

Set a named value on an object and return that object so multiple calls can be chained.

Set ( this obj, string name, bool value ) : JContainer

Set a named value on an object and return that object so multiple calls can be chained.

Set ( this obj, string name, double value ) : JContainer

Set a named value on an object and return that object so multiple calls can be chained.

Set ( this obj, string name, int value ) : JContainer

Set a named value on an object and return that object so multiple calls can be chained.

Set ( this obj, string name, string value ) : JContainer

Set a named value on an object and return that object so multiple calls can be chained.

TryConvert ( this value, object &propertyValue ) : bool

Try to convert a value to a CLR object.

TrySet ( this obj, string name, object value ) : bool

Set a named value on an object of any type. Unlike the other set overloads, this will attempt to convert arbitrary CLR values into the correct JSON types.

Приватные методы

Метод Описание
NumericCanRoundtrip ( object value, Type desiredType ) : bool

Ensure that a numeric value can safely roundtrip as a double.

Описание методов

Append() публичный статический Метод

Add an element to a JSON array.
public static Append ( this array, JToken value ) : Newtonsoft.Json.Linq.JArray
array this The array to add to.
value JToken The element to add.
Результат Newtonsoft.Json.Linq.JArray

AsArray() публичный статический Метод

Convert a JSON value into an array, returning null if it's unable.
public static AsArray ( this value ) : Newtonsoft.Json.Linq.JArray
value this The value to convert.
Результат Newtonsoft.Json.Linq.JArray

AsBool() публичный статический Метод

Convert a JSON value into a bool, returning null if it's unable.
public static AsBool ( this value ) : bool?
value this The value to convert.
Результат bool?

AsInteger() публичный статический Метод

Convert a JSON value into an int, returning null if it's unable.
public static AsInteger ( this value ) : int?
value this The value to convert.
Результат int?

AsNumber() публичный статический Метод

Convert a JSON value into a double, returning null if it's unable.
public static AsNumber ( this value ) : double?
value this The value to convert.
Результат double?

AsObject() публичный статический Метод

Convert a JSON value into an object, returning null if it's unable.
public static AsObject ( this value ) : Newtonsoft.Json.Linq.JObject
value this The value to convert.
Результат Newtonsoft.Json.Linq.JObject

AsString() публичный статический Метод

Convert a JSON value into a string, returning null if it's unable.
public static AsString ( this value ) : string
value this The value to convert.
Результат string

Get() публичный статический Метод

Gets a named value from an object.
public static Get ( this value, string name ) : JToken
value this /// The object to check (though the type is IJsonValue so multiple /// calls to Get can be chained together). ///
name string The name of the value to lookup.
Результат JToken

GetPropertyValues() публичный статический Метод

Enumerate the member name/value pairs of a JSON object.
public static GetPropertyValues ( this value ) : JToken>>.IEnumerable
value this A JSON object.
Результат JToken>>.IEnumerable

IsNull() публичный статический Метод

Determine if the value represents null.
public static IsNull ( this value ) : bool
value this The value to check.
Результат bool

Null() публичный статический Метод

Get a null JSON value (that when serialized will stay null rather than not being written out).
public static Null ( ) : JToken
Результат JToken

Set() публичный статический Метод

Set a named value on an object and return that object so multiple calls can be chained.
public static Set ( this obj, string name, JToken value ) : JContainer
obj this The object to set the value on.
name string The name to set.
value JToken The value to set.
Результат JContainer

Set() публичный статический Метод

Set a named value on an object and return that object so multiple calls can be chained.
public static Set ( this obj, string name, bool value ) : JContainer
obj this The object to set the value on.
name string The name to set.
value bool The value to set.
Результат JContainer

Set() публичный статический Метод

Set a named value on an object and return that object so multiple calls can be chained.
public static Set ( this obj, string name, double value ) : JContainer
obj this The object to set the value on.
name string The name to set.
value double The value to set.
Результат JContainer

Set() публичный статический Метод

Set a named value on an object and return that object so multiple calls can be chained.
public static Set ( this obj, string name, int value ) : JContainer
obj this The object to set the value on.
name string The name to set.
value int The value to set.
Результат JContainer

Set() публичный статический Метод

Set a named value on an object and return that object so multiple calls can be chained.
public static Set ( this obj, string name, string value ) : JContainer
obj this The object to set the value on.
name string The name to set.
value string The value to set.
Результат JContainer

TryConvert() публичный статический Метод

Try to convert a value to a CLR object.
public static TryConvert ( this value, object &propertyValue ) : bool
value this The value to convert.
propertyValue object The converted value.
Результат bool

TrySet() публичный статический Метод

Set a named value on an object of any type. Unlike the other set overloads, this will attempt to convert arbitrary CLR values into the correct JSON types.
public static TrySet ( this obj, string name, object value ) : bool
obj this The object to set the value on.
name string The name of the value to set.
value object The value to set.
Результат bool