Sdílet prostřednictvím


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.

public ref class JsonValue sealed : IJsonValue, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class JsonValue final : IJsonValue, IStringable
[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
Public NotInheritable Class JsonValue
Implements IJsonValue, IStringable
Inheritance
Object Platform::Object IInspectable 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

See also