Table of Contents

Class JValue

Namespace
Newtonsoft.Json.Linq
Assembly
Newtonsoft.Json.dll

Represents a value in JSON (string, integer, date, etc).

public class JValue : JToken, IJEnumerable<JToken>, IEnumerable<JToken>, IEnumerable, IJsonLineInfo, ICloneable, IEquatable<JValue>, IFormattable, IComparable, IComparable<JValue>
Inheritance
JValue
Implements
Derived
Inherited Members
Extension Methods

Constructors

JValue(JValue)

Initializes a new instance of the JValue class from another JValue object.

public JValue(JValue other)

Parameters

other JValue

A JValue object to copy from.

JValue(bool)

Initializes a new instance of the JValue class with the given value.

public JValue(bool value)

Parameters

value bool

The value.

JValue(DateTime)

Initializes a new instance of the JValue class with the given value.

public JValue(DateTime value)

Parameters

value DateTime

The value.

JValue(double)

Initializes a new instance of the JValue class with the given value.

public JValue(double value)

Parameters

value double

The value.

JValue(Guid)

Initializes a new instance of the JValue class with the given value.

public JValue(Guid value)

Parameters

value Guid

The value.

JValue(long)

Initializes a new instance of the JValue class with the given value.

public JValue(long value)

Parameters

value long

The value.

JValue(object)

Initializes a new instance of the JValue class with the given value.

public JValue(object value)

Parameters

value object

The value.

JValue(string)

Initializes a new instance of the JValue class with the given value.

public JValue(string value)

Parameters

value string

The value.

JValue(TimeSpan)

Initializes a new instance of the JValue class with the given value.

public JValue(TimeSpan value)

Parameters

value TimeSpan

The value.

JValue(ulong)

Initializes a new instance of the JValue class with the given value.

[CLSCompliant(false)]
public JValue(ulong value)

Parameters

value ulong

The value.

JValue(Uri)

Initializes a new instance of the JValue class with the given value.

public JValue(Uri value)

Parameters

value Uri

The value.

Properties

HasValues

Gets a value indicating whether this token has childen tokens.

public override bool HasValues { get; }

Property Value

bool

true if this token has child values; otherwise, false.

Type

Gets the node type for this JToken.

public override JTokenType Type { get; }

Property Value

JTokenType

The type.

Value

Gets or sets the underlying token value.

public object Value { get; set; }

Property Value

object

The underlying token value.

Methods

CompareTo(JValue)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(JValue obj)

Parameters

obj JValue

An object to compare with this instance.

Returns

int

A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than obj. Zero This instance is equal to obj. Greater than zero This instance is greater than obj.

Exceptions

ArgumentException

obj is not the same type as this instance.

CreateComment(string)

Creates a JValue comment with the given value.

public static JValue CreateComment(string value)

Parameters

value string

The value.

Returns

JValue

A JValue comment with the given value.

CreateString(string)

Creates a JValue string with the given value.

public static JValue CreateString(string value)

Parameters

value string

The value.

Returns

JValue

A JValue string with the given value.

Equals(JValue)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(JValue other)

Parameters

other JValue

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Exceptions

NullReferenceException

The obj parameter is null.

GetHashCode()

Serves as a hash function for a particular type.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

ToString(IFormatProvider)

Returns a string that represents this instance.

public string ToString(IFormatProvider formatProvider)

Parameters

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

ToString(string)

Returns a string that represents this instance.

public string ToString(string format)

Parameters

format string

The format.

Returns

string

A string that represents this instance.

ToString(string, IFormatProvider)

Returns a string that represents this instance.

public string ToString(string format, IFormatProvider formatProvider)

Parameters

format string

The format.

formatProvider IFormatProvider

The format provider.

Returns

string

A string that represents this instance.

WriteTo(JsonWriter, params JsonConverter[])

Writes this token to a JsonWriter.

public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)

Parameters

writer JsonWriter

A JsonWriter into which this method will write.

converters JsonConverter[]

A collection of JsonConverter which will be used when writing the token.