Share via


JsonValue Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

This is the abstract base class for JavaScript Object Notation (JSON) common language runtime (CLR) types.

Inheritance Hierarchy

System.Object
  System.Json.JsonValue
    System.Json.JsonArray
    System.Json.JsonObject
    System.Json.JsonPrimitive

Namespace:  System.Json
Assembly:  System.Json (in System.Json.dll)

Syntax

'Declaration
<DefaultMemberAttribute("Item")> _
Public MustInherit Class JsonValue _
    Implements IEnumerable
[DefaultMemberAttribute("Item")]
public abstract class JsonValue : IEnumerable

The JsonValue type exposes the following members.

Properties

  Name Description
Public property Count This method is not supported and throws an exception when called.
Public property Item[Int32] This indexer is not supported for this base class and throws an exception.
Public property Item[String] This indexer is not supported for this base class and throws an exception.
Public property JsonType When implemented in a derived class, indicates the JSON CLR type represented by the derived type.

Top

Methods

  Name Description
Public method ContainsKey Throws an InvalidOperationException.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodStatic member Load(Stream) Deserializes text-based JSON from a stream into a JSON CLR type.
Public methodStatic member Load(TextReader) Deserializes text-based JSON from a text reader into a JSON CLR type.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic member Parse Deserializes text-based JSON into a JSON CLR type.
Public method Save(Stream) When implemented in a derived class, serializes the JsonValue CLR type into text-based JSON using a stream.
Public method Save(TextWriter) Serializes the JsonValue CLR type into text-based JSON using a text writer.
Public method ToString Saves (serializes) this JSON CLR type into text-based JSON. (Overrides Object.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Implicit(Boolean to JsonValue) Enables implicit casts from type Boolean to a JsonPrimitive.
Public operatorStatic member Implicit(Byte to JsonValue) Enables implicit casts from type Byte to a JsonPrimitive.
Public operatorStatic member Implicit(Char to JsonValue) Enables implicit casts from type Char to a JsonPrimitive.
Public operatorStatic member Implicit(DateTime to JsonValue) Enables implicit casts from type DateTime to a JsonPrimitive.
Public operatorStatic member Implicit(DateTimeOffset to JsonValue) Enables implicit casts from type DateTimeOffset to a JsonObject.
Public operatorStatic member Implicit(Decimal to JsonValue) Enables implicit casts from type Decimal to a JsonPrimitive.
Public operatorStatic member Implicit(Double to JsonValue) Enables implicit casts from type Double to a JsonPrimitive.
Public operatorStatic member Implicit(Guid to JsonValue) Enables implicit casts from type Guid to a JsonPrimitive.
Public operatorStatic member Implicit(Int16 to JsonValue) Enables implicit casts from type Int16 to a JsonPrimitive.
Public operatorStatic member Implicit(Int32 to JsonValue) Enables implicit casts from type Int32 to a JsonPrimitive.
Public operatorStatic member Implicit(Int64 to JsonValue) Enables implicit casts from type Int64 to a JsonPrimitive.
Public operatorStatic member Implicit(JsonValue to DateTime) Enables implicit casts from an instance of type JsonValue to a Datetime object.
Public operatorStatic member Implicit(JsonValue to TimeSpan) Enables implicit casts from an instance of type JsonValue to a TimeSpan object.
Public operatorStatic member Implicit(JsonValue to Boolean) Enables implicit casts from an instance of type JsonValue to a Boolean object.
Public operatorStatic member Implicit(JsonValue to Char) Enables implicit casts from an instance of type JsonValue to a Char object.
Public operatorStatic member Implicit(JsonValue to Int64) Enables implicit casts from an instance of type JsonValue to a Int64 object.
Public operatorStatic member Implicit(JsonValue to Decimal) Enables implicit casts from an instance of type JsonValue to a Decimal object.
Public operatorStatic member Implicit(JsonValue to Int32) Enables implicit casts from an instance of type JsonValue to a Int32 object.
Public operatorStatic member Implicit(JsonValue to UInt64) Enables implicit casts from an instance of type JsonValue to a UInt64 object.
Public operatorStatic member Implicit(JsonValue to String) Enables implicit casts from an instance of type JsonValue to a String object.
Public operatorStatic member Implicit(JsonValue to DateTimeOffset) Enables implicit casts from an instance of type JsonValue to a DateTimeOffset object.
Public operatorStatic member Implicit(JsonValue to Single) Enables implicit casts from an instance of type JsonValue to a Single object.
Public operatorStatic member Implicit(JsonValue to Double) Enables implicit casts from an instance of type JsonValue to a Double object.
Public operatorStatic member Implicit(JsonValue to SByte) Enables implicit casts from an instance of type JsonValue to a SByte object.
Public operatorStatic member Implicit(JsonValue to Byte) Enables implicit casts from an instance of type JsonValue to a Byte object.
Public operatorStatic member Implicit(JsonValue to Uri) Enables implicit casts from an instance of type JsonValue to a Uri object.
Public operatorStatic member Implicit(JsonValue to UInt16) Enables implicit casts from an instance of type JsonValue to a UInt16 object.
Public operatorStatic member Implicit(JsonValue to UInt32) Enables implicit casts from an instance of type JsonValue to a UInt32 object.
Public operatorStatic member Implicit(JsonValue to Int16) Enables implicit casts from an instance of type JsonValue to a Int16 object.
Public operatorStatic member Implicit(JsonValue to Guid) Enables implicit casts from an instance of type JsonValue to a Guid object.
Public operatorStatic member Implicit(SByte to JsonValue) Enables implicit casts from type SByte to a JsonPrimitive.
Public operatorStatic member Implicit(Single to JsonValue) Enables implicit casts from type Single to a JsonPrimitive.
Public operatorStatic member Implicit(String to JsonValue) Enables implicit casts from type String to a JsonPrimitive.
Public operatorStatic member Implicit(TimeSpan to JsonValue) Enables implicit casts from type Timespan to a JsonPrimitive.
Public operatorStatic member Implicit(UInt16 to JsonValue) Enables implicit casts from type UInt16 to a JsonPrimitive.
Public operatorStatic member Implicit(UInt32 to JsonValue) Enables implicit casts from type UInt32 to a JsonPrimitive.
Public operatorStatic member Implicit(UInt64 to JsonValue) Enables implicit casts from type UInt64 to a JsonPrimitive.
Public operatorStatic member Implicit(Uri to JsonValue) Enables implicit casts from type Uri to a JsonPrimitive.

Top

Extension Methods

  Name Description
Public Extension Method AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IEnumerable.GetEnumerator This method is not supported for this base class and throws an exception.

Top

Remarks

The JSON CLR types JsonPrimitive, JsonArray, and JsonObject all inherit from this base class. It contains functionality common to all JSON CLR types, which is accessed through abstract methods and inheritance from this type. In particular, it contains a set of Implicit() operations that supports implicit static type conversion that enables you to treat JSON in a weakly typed manner.

Note that you cannot create custom classes that derive from JsonValue because one of its abstract properties is internal. This means that only types like JsonPrimitive that are in the System.Json.dll are allowed to derive from the class.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference