Class JsonValue
public class JsonValue : ICloneable
- Inheritance
-
JsonValue
- Implements
- Derived
- Inherited Members
Constructors
JsonValue(bool)
public JsonValue(bool f)
Parameters
f
bool
JsonValue(decimal)
public JsonValue(decimal n)
Parameters
n
decimal
JsonValue(double)
public JsonValue(double n)
Parameters
n
double
JsonValue(int)
public JsonValue(int n)
Parameters
n
int
JsonValue(long)
public JsonValue(long n)
Parameters
n
long
JsonValue(float)
public JsonValue(float n)
Parameters
n
float
JsonValue(string)
public JsonValue(string s)
Parameters
s
string
Fields
Null
public static readonly JsonValue Null
Field Value
Undefined
public static readonly JsonValue Undefined
Field Value
Properties
this[int]
Access to the indexed elements of a JSON array.
public JsonValue this[int nIndex] { get; set; }
Parameters
nIndex
int
Property Value
Remarks
Access an index that is outside of the range of the array will return null
,
and NOT a JsonValue of type Undefined.
Exceptions
- JsonTypeException
Thrown is this is not an Array.
- ArgumentOutOfRangeException
An attempt was made to set a value with an index outside of the range of the array. It is not possible to grow an array just by setting values outside of the current range of values.
this[string]
Access to the named properties of a JSON object.
public JsonValue this[string sName] { get; set; }
Parameters
sName
stringName of property, or path to a nested property seperated with dots.
Property Value
Remarks
Setting a property to null
will delete that property, and not insert a
new JsonValue of type Null. If you want an
empty property you have to explicitly pass an appropriate JsonValue.
Getting a property that is not defined will return null
and NOT a
JsonValue of type Undefined.
Exceptions
- ArgumentNullException
The index sName was
null
.- JsonTypeException
Thrown if this is not an Object.
JsonType
public JsonType JsonType { get; }
Property Value
Value
The primitive value.
public object Value { get; }
Property Value
ValueAsBoolean
public bool ValueAsBoolean { get; }
Property Value
ValueAsNumber
public double ValueAsNumber { get; }
Property Value
ValueAsString
Returns the value as a string.
public string ValueAsString { get; }
Property Value
Remarks
If this value is not a String, then this method attempts to convert it to a string, first. Conversion is done using the usual JavaScript conversion rules, including conversion of type Undefined to string "undefined" and type Null to string "null".
Methods
Clone()
public object Clone()
Returns
Load(Stream)
public static JsonValue Load(Stream aStream)
Parameters
aStream
Stream
Returns
Load(TextReader)
public static JsonValue Load(TextReader aTextReader)
Parameters
aTextReader
TextReader
Returns
Load(string)
public static JsonValue Load(string sFileName)
Parameters
sFileName
string
Returns
Parse(byte[])
public static JsonValue Parse(byte[] vbJson)
Parameters
vbJson
byte[]
Returns
Parse(string)
public static JsonValue Parse(string sJson)
Parameters
sJson
string
Returns
Save(Stream)
public void Save(Stream aStream)
Parameters
aStream
Stream
Save(TextWriter)
public void Save(TextWriter aTextWriter)
Parameters
aTextWriter
TextWriter
Save(string)
public void Save(string sFileName)
Parameters
sFileName
string
ToByteArray()
public byte[] ToByteArray()
Returns
- byte[]
ToString()
Converts this value into its JSON string representation.
public override string ToString()
Returns
Operators
implicit operator bool(JsonValue)
public static implicit operator bool(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator decimal(JsonValue)
public static implicit operator decimal(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator double(JsonValue)
public static implicit operator double(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator int(JsonValue)
public static implicit operator int(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator long(JsonValue)
public static implicit operator long(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator float(JsonValue)
public static implicit operator float(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator string(JsonValue)
public static implicit operator string(JsonValue aValue)
Parameters
aValue
JsonValue
Returns
implicit operator JsonValue(bool)
public static implicit operator JsonValue(bool f)
Parameters
f
bool
Returns
implicit operator JsonValue(decimal)
public static implicit operator JsonValue(decimal n)
Parameters
n
decimal
Returns
implicit operator JsonValue(double)
public static implicit operator JsonValue(double n)
Parameters
n
double
Returns
implicit operator JsonValue(int)
public static implicit operator JsonValue(int n)
Parameters
n
int
Returns
implicit operator JsonValue(long)
public static implicit operator JsonValue(long n)
Parameters
n
long
Returns
implicit operator JsonValue(float)
public static implicit operator JsonValue(float n)
Parameters
n
float
Returns
implicit operator JsonValue(string)
public static implicit operator JsonValue(string s)
Parameters
s
string