Sdílet prostřednictvím


JsonPrimitive Class

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

Represents a JavaScript Object Notation (JSON) primitive type in the common language runtime (CLR).

Inheritance Hierarchy

System.Object
  System.Json.JsonValue
    System.Json.JsonPrimitive

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

Syntax

'Declaration
Public Class JsonPrimitive _
    Inherits JsonValue
public class JsonPrimitive : JsonValue

The JsonPrimitive type exposes the following members.

Constructors

  Name Description
Public method JsonPrimitive(Boolean) Initializes a new instance of a JsonPrimitive type with a Boolean type.
Public method JsonPrimitive(Byte) Initializes a new instance of a JsonPrimitive type with a Byte type.
Public method JsonPrimitive(Char) Initializes a new instance of a JsonPrimitive type with a Char type.
Public method JsonPrimitive(DateTime) Initializes a new instance of a JsonPrimitive type with a DateTime type.
Public method JsonPrimitive(Decimal) Initializes a new instance of a JsonPrimitive type with a Decimal type.
Public method JsonPrimitive(Double) Initializes a new instance of a JsonPrimitive type with a Double type.
Public method JsonPrimitive(Guid) Initializes a new instance of a JsonPrimitive type with a Guid type.
Public method JsonPrimitive(Int16) Initializes a new instance of a JsonPrimitive type with a Int16 type.
Public method JsonPrimitive(Int32) Initializes a new instance of a JsonPrimitive type with a Int32 type.
Public method JsonPrimitive(Int64) Initializes a new instance of a JsonPrimitive type with a Int64 type.
Public method JsonPrimitive(SByte) Initializes a new instance of a JsonPrimitive type with a SByte type.
Public method JsonPrimitive(Single) Initializes a new instance of a JsonPrimitive type with a Single type.
Public method JsonPrimitive(String) Initializes a new instance of a JsonPrimitive type with a String type.
Public method JsonPrimitive(TimeSpan) Initializes a new instance of a JsonPrimitive type with a TimeSpan type.
Public method JsonPrimitive(UInt16) Initializes a new instance of a JsonPrimitive type with a UInt16 type.
Public method JsonPrimitive(UInt32) Initializes a new instance of a JsonPrimitive type with a UInt32 type.
Public method JsonPrimitive(UInt64) Initializes a new instance of a JsonPrimitive type with a UInt64 type.
Public method JsonPrimitive(Uri) Initializes a new instance of a JsonPrimitive type with a Uri type.

Top

Properties

  Name Description
Public property Count This method is not supported and throws an exception when called. (Inherited from JsonValue.)
Public property Item[Int32] This indexer is not supported for this base class and throws an exception. (Inherited from JsonValue.)
Public property Item[String] This indexer is not supported for this base class and throws an exception. (Inherited from JsonValue.)
Public property JsonType Gets the JsonType that is associated with this JsonPrimitive object. (Overrides JsonValue.JsonType.)

Top

Methods

  Name Description
Public method ContainsKey Throws an InvalidOperationException. (Inherited from JsonValue.)
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.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Save(Stream) Serializes the JsonPrimitive object into text-based JSON. (Overrides JsonValue.Save(Stream).)
Public method Save(TextWriter) Serializes the JsonValue CLR type into text-based JSON using a text writer. (Inherited from JsonValue.)
Public method ToString Saves (serializes) this JSON CLR type into text-based JSON. (Inherited from JsonValue.)

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. (Inherited from JsonValue.)

Top

Remarks

The exact type stored is indicated by the JsonType property. The public constructors in this class allow the creation of JsonPrimitive objects associated with three JsonType objects: Number, String, and Boolean.

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