This topic has not yet been rated - Rate this topic

JsonValue Class

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

Namespace:  System.Json
Assembly:  System.Json (in System.Json.dll)
[DefaultMemberAttribute("Item")]
public abstract class JsonValue : IEnumerable

The JsonValue type exposes the following members.

  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
  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 method Static member Load(Stream) Deserializes text-based JSON from a stream into a JSON CLR type.
Public method Static 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 method Static 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
  Name Description
Public operator Static member Implicit(Boolean to JsonValue) Enables implicit casts from type Boolean to a JsonPrimitive.
Public operator Static member Implicit(Byte to JsonValue) Enables implicit casts from type Byte to a JsonPrimitive.
Public operator Static member Implicit(Char to JsonValue) Enables implicit casts from type Char to a JsonPrimitive.
Public operator Static member Implicit(DateTime to JsonValue) Enables implicit casts from type DateTime to a JsonPrimitive.
Public operator Static member Implicit(DateTimeOffset to JsonValue) Enables implicit casts from type DateTimeOffset to a JsonObject.
Public operator Static member Implicit(Decimal to JsonValue) Enables implicit casts from type Decimal to a JsonPrimitive.
Public operator Static member Implicit(Double to JsonValue) Enables implicit casts from type Double to a JsonPrimitive.
Public operator Static member Implicit(Guid to JsonValue) Enables implicit casts from type Guid to a JsonPrimitive.
Public operator Static member Implicit(Int16 to JsonValue) Enables implicit casts from type Int16 to a JsonPrimitive.
Public operator Static member Implicit(Int32 to JsonValue) Enables implicit casts from type Int32 to a JsonPrimitive.
Public operator Static member Implicit(Int64 to JsonValue) Enables implicit casts from type Int64 to a JsonPrimitive.
Public operator Static member Implicit(JsonValue to DateTime) Enables implicit casts from an instance of type JsonValue to a Datetime object.
Public operator Static member Implicit(JsonValue to TimeSpan) Enables implicit casts from an instance of type JsonValue to a TimeSpan object.
Public operator Static member Implicit(JsonValue to Boolean) Enables implicit casts from an instance of type JsonValue to a Boolean object.
Public operator Static member Implicit(JsonValue to Char) Enables implicit casts from an instance of type JsonValue to a Char object.
Public operator Static member Implicit(JsonValue to Int64) Enables implicit casts from an instance of type JsonValue to a Int64 object.
Public operator Static member Implicit(JsonValue to Decimal) Enables implicit casts from an instance of type JsonValue to a Decimal object.
Public operator Static member Implicit(JsonValue to Int32) Enables implicit casts from an instance of type JsonValue to a Int32 object.
Public operator Static member Implicit(JsonValue to UInt64) Enables implicit casts from an instance of type JsonValue to a UInt64 object.
Public operator Static member Implicit(JsonValue to String) Enables implicit casts from an instance of type JsonValue to a String object.
Public operator Static member Implicit(JsonValue to DateTimeOffset) Enables implicit casts from an instance of type JsonValue to a DateTimeOffset object.
Public operator Static member Implicit(JsonValue to Single) Enables implicit casts from an instance of type JsonValue to a Single object.
Public operator Static member Implicit(JsonValue to Double) Enables implicit casts from an instance of type JsonValue to a Double object.
Public operator Static member Implicit(JsonValue to SByte) Enables implicit casts from an instance of type JsonValue to a SByte object.
Public operator Static member Implicit(JsonValue to Byte) Enables implicit casts from an instance of type JsonValue to a Byte object.
Public operator Static member Implicit(JsonValue to Uri) Enables implicit casts from an instance of type JsonValue to a Uri object.
Public operator Static member Implicit(JsonValue to UInt16) Enables implicit casts from an instance of type JsonValue to a UInt16 object.
Public operator Static member Implicit(JsonValue to UInt32) Enables implicit casts from an instance of type JsonValue to a UInt32 object.
Public operator Static member Implicit(JsonValue to Int16) Enables implicit casts from an instance of type JsonValue to a Int16 object.
Public operator Static member Implicit(JsonValue to Guid) Enables implicit casts from an instance of type JsonValue to a Guid object.
Public operator Static member Implicit(SByte to JsonValue) Enables implicit casts from type SByte to a JsonPrimitive.
Public operator Static member Implicit(Single to JsonValue) Enables implicit casts from type Single to a JsonPrimitive.
Public operator Static member Implicit(String to JsonValue) Enables implicit casts from type String to a JsonPrimitive.
Public operator Static member Implicit(TimeSpan to JsonValue) Enables implicit casts from type Timespan to a JsonPrimitive.
Public operator Static member Implicit(UInt16 to JsonValue) Enables implicit casts from type UInt16 to a JsonPrimitive.
Public operator Static member Implicit(UInt32 to JsonValue) Enables implicit casts from type UInt32 to a JsonPrimitive.
Public operator Static member Implicit(UInt64 to JsonValue) Enables implicit casts from type UInt64 to a JsonPrimitive.
Public operator Static member Implicit(Uri to JsonValue) Enables implicit casts from type Uri to a JsonPrimitive.
Top
  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
  Name Description
Explicit interface implemetation Private method IEnumerable.GetEnumerator This method is not supported for this base class and throws an exception.
Top

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.

Silverlight

Supported in: 5, 4, 3

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ