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
valueboolThe value.
JValue(DateTime)
Initializes a new instance of the JValue class with the given value.
public JValue(DateTime value)
Parameters
valueDateTimeThe value.
JValue(double)
Initializes a new instance of the JValue class with the given value.
public JValue(double value)
Parameters
valuedoubleThe value.
JValue(Guid)
Initializes a new instance of the JValue class with the given value.
public JValue(Guid value)
Parameters
valueGuidThe value.
JValue(long)
Initializes a new instance of the JValue class with the given value.
public JValue(long value)
Parameters
valuelongThe value.
JValue(object)
Initializes a new instance of the JValue class with the given value.
public JValue(object value)
Parameters
valueobjectThe value.
JValue(string)
Initializes a new instance of the JValue class with the given value.
public JValue(string value)
Parameters
valuestringThe value.
JValue(TimeSpan)
Initializes a new instance of the JValue class with the given value.
public JValue(TimeSpan value)
Parameters
valueTimeSpanThe value.
JValue(ulong)
Initializes a new instance of the JValue class with the given value.
[CLSCompliant(false)]
public JValue(ulong value)
Parameters
valueulongThe value.
JValue(Uri)
Initializes a new instance of the JValue class with the given value.
public JValue(Uri value)
Parameters
valueUriThe value.
Properties
HasValues
Gets a value indicating whether this token has childen tokens.
public override bool HasValues { get; }
Property Value
- bool
trueif 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
objJValueAn 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
objis not the same type as this instance.
CreateComment(string)
Creates a JValue comment with the given value.
public static JValue CreateComment(string value)
Parameters
valuestringThe value.
Returns
CreateString(string)
Creates a JValue string with the given value.
public static JValue CreateString(string value)
Parameters
valuestringThe value.
Returns
Equals(JValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(JValue other)
Parameters
otherJValueAn object to compare with this object.
Returns
- bool
true if the current object is equal to the
otherparameter; otherwise, false.
Equals(object)
public override bool Equals(object obj)
Parameters
Returns
Exceptions
- NullReferenceException
The
objparameter 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
formatProviderIFormatProviderThe format provider.
Returns
ToString(string)
Returns a string that represents this instance.
public string ToString(string format)
Parameters
formatstringThe format.
Returns
ToString(string, IFormatProvider)
Returns a string that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
formatstringThe format.
formatProviderIFormatProviderThe format provider.
Returns
WriteTo(JsonWriter, params JsonConverter[])
Writes this token to a JsonWriter.
public override void WriteTo(JsonWriter writer, params JsonConverter[] converters)
Parameters
writerJsonWriterA JsonWriter into which this method will write.
convertersJsonConverter[]A collection of JsonConverter which will be used when writing the token.