JsonValue Class

Definition

Implements the IJsonValue interface which represents a JSON value.

A JsonValue object can represent the three primitive JSON value types of Boolean, Number and String, and can also represent the complex value types of Array and Object by providing ways to access them.

C#
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class JsonValue : IJsonValue, IStringable
Inheritance
Object JsonValue
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

A JsonValue object has overloaded constructors to instantiate a new object from a JSON String, Number or Boolean value and a default constructor that instantiates a JsonValue object with a ValueType of NULL.

For an example of how these class methods are used to parse a number or string from a JSON string and convert it into a JsonValue object, see Using JavaScript Object Notation (JSON).

Properties

ValueType

Gets the type of the encapsulated JSON value. Possible types are defined by JsonValueType.

Methods

CreateBooleanValue(Boolean)

Creates a JsonValue from a Boolean.

CreateNullValue()

Creates a JsonValue with a NULL value.

CreateNumberValue(Double)

Creates a JsonValue from a Number (Double).

CreateStringValue(String)

Creates the string for a JsonValue.

GetArray()

Gets an array if the ValueType of the encapsulated value is Array.

GetBoolean()

Gets the Boolean if the ValueType of the encapsulated value is Boolean.

GetNumber()

Gets the number (a Double) if the ValueType of the encapsulated value is Number.

GetObject()

Gets a JsonObject if the ValueType of the encapsulated value is Object.

GetString()

Gets a String if the ValueType of the encapsulated value is String.

Parse(String)

Parses the specified JSON string into a JsonValue.

Note

This method will throw an exception if the provided JSON string is not valid. Use of JsonObject.TryParse is a recommended alternative. A TryParse call will return a boolean value to indicate success or failure and, if successful, the resultant JsonValue.

Stringify()

Retrieves the JSON representation of the encapsulated value.

ToString()

Retrieves the JSON representation of the encapsulated value.

TryParse(String, JsonValue)

Parses the specified string into a JsonValue.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also