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)
public JValue(JValue other)
Parameters
JValue(bool)
Initializes a new instance of the JValue class with the given value.
public JValue(bool value)
Parameters
value
boolThe value.
JValue(DateTime)
Initializes a new instance of the JValue class with the given value.
public JValue(DateTime value)
Parameters
value
DateTimeThe value.
JValue(double)
Initializes a new instance of the JValue class with the given value.
public JValue(double value)
Parameters
value
doubleThe value.
JValue(Guid)
Initializes a new instance of the JValue class with the given value.
public JValue(Guid value)
Parameters
value
GuidThe value.
JValue(long)
Initializes a new instance of the JValue class with the given value.
public JValue(long value)
Parameters
value
longThe value.
JValue(object)
Initializes a new instance of the JValue class with the given value.
public JValue(object value)
Parameters
value
objectThe value.
JValue(string)
Initializes a new instance of the JValue class with the given value.
public JValue(string value)
Parameters
value
stringThe value.
JValue(TimeSpan)
Initializes a new instance of the JValue class with the given value.
public JValue(TimeSpan value)
Parameters
value
TimeSpanThe value.
JValue(ulong)
Initializes a new instance of the JValue class with the given value.
[CLSCompliant(false)]
public JValue(ulong value)
Parameters
value
ulongThe value.
JValue(Uri)
Initializes a new instance of the JValue class with the given value.
public JValue(Uri value)
Parameters
value
UriThe 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
JValueAn 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 toobj
. Greater than zero This instance is greater thanobj
.
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
stringThe value.
Returns
CreateString(string)
Creates a JValue string with the given value.
public static JValue CreateString(string value)
Parameters
value
stringThe value.
Returns
Equals(JValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(JValue other)
Parameters
other
JValueAn object to compare with this object.
Returns
- bool
true if the current object is equal to the
other
parameter; otherwise, false.
Equals(object)
public override bool Equals(object obj)
Parameters
Returns
Exceptions
- NullReferenceException
The
obj
parameter is null.
GetHashCode()
Serves as a hash function for a particular type.
public override int GetHashCode()
Returns
ToString()
Returns a string that represents this instance.
public override string ToString()
Returns
ToString(IFormatProvider)
Returns a string that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
formatProvider
IFormatProviderThe format provider.
Returns
ToString(string)
Returns a string that represents this instance.
public string ToString(string format)
Parameters
format
stringThe format.
Returns
ToString(string, IFormatProvider)
Returns a string that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format.
formatProvider
IFormatProviderThe format provider.
Returns
WriteTo(JsonWriter, params JsonConverter[])
Writes this token to a JsonWriter.
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
Parameters
writer
JsonWriterA JsonWriter into which this method will write.
converters
JsonConverter[]A collection of JsonConverter which will be used when writing the token.