IJsonValue
Description
- Derived from
- Extended by
-
JsonValue sealed
Represents read-only access to a parsed JSON value.
A JSON value always has one of the following data types:
The JSON value may be accessed via the following getter methods, which will perform value conversions, if possible:
-
array: Count, GetElement, Elements -
boolean: GetBoolean -
null: n/a -
number: GetFloat32, GetFloat64 -
object: Count, GetMember1 -
string: GetString
Use IJsonValue.ToFile and IJsonValue.ToString to generate parsable JSON code. To parse JSON code, use JsonValue.From2 and JsonValue.FromFile.
- See also
Public / Methods
Copy
Creates a mutable copy of this JSON value.
Modifying the returned JsonValue will not affect this JSON value.
GetBoolean
Returns this JSON value as a boolean value.
The following values are returned by this method, depending on the JSON value type:
-
array: defaultValue opt -
boolean: value -
integer:falseif value is0, otherwisetrue -
null: defaultValue opt -
number:falseif value is0, otherwisetrue -
object: defaultValue opt -
string:trueif value is'true', otherwisefalse
GetElement
Returns the index in-th array element of this JSON value.
The following values are returned by this method, depending on the JSON value type:
-
array: index in-th element of value or JsonValue.Null if out of range -
boolean: JsonValue.Null -
integer: JsonValue.Null -
null: JsonValue.Null -
number: JsonValue.Null -
object: JsonValue.Null -
string: JsonValue.Null
GetFloat32
Returns this JSON value as a 32-bit floating point value.
The following values are returned by this method, depending on the JSON value type:
-
array: defaultValue opt -
boolean:1fortrue,0forfalse -
integer: value, cast to integer -
null: defaultValue opt -
number: value -
object: defaultValue opt -
string: value parsed with Parse.Number, on failure defaultValue opt
GetFloat64
Returns this JSON value as a 64-bit floating point value.
The following values are returned by this method, depending on the JSON value type:
-
array: defaultValue opt -
boolean:1fortrue,0forfalse -
integer: value, cast to integer -
null: defaultValue opt -
number: value -
object: defaultValue opt -
string: value parsed with Parse.Number, on failure defaultValue opt
GetInt32
Returns this JSON value as a 32-bit integer value.
The following values are returned by this method, depending on the JSON value type:
-
array: defaultValue opt -
boolean:1fortrue,0forfalse -
integer: value -
null: defaultValue opt -
number: value, cast to number -
object: defaultValue opt -
string: value parsed with Parse.Integer, on failure parsed with Parse.Number and cast to integer, on failure defaultValue opt
GetInt64
Returns this JSON value as a 64-bit integer value.
The following values are returned by this method, depending on the JSON value type:
-
array: defaultValue opt -
boolean:1fortrue,0forfalse -
integer: value -
null: defaultValue opt -
number: value, cast to number -
object: defaultValue opt -
string: value parsed with Parse.Integer, on failure parsed with Parse.Number and cast to integer, on failure defaultValue opt
GetMember
2 overloads
Returns the value of the given object member.
Returns the value of the given object member.
- See also
GetMemberComment
Returns the comment of the given object member.
Comments are not a part of the official JSON specification and should not be used to represent data. When outputting JSON code in plain ASCII, all non-ASCII characters in comments will be replaced with '?'.
- See also
GetString
Returns this JSON value as a string.
-
array: defaultValue opt -
boolean:'true'fortrue,'false'forfalse -
integer: Format.ThisInt with FormatFlags.Default for value -
null: defaultValue opt -
number: Format.ThisNum with FormatFlags.Precision17 for value -
object: defaultValue opt -
string: value
Public / Attributes
Elements
Returns the array elements of this JSON value.
This collection should only be used if Count and GetElement and not suitable.
Extensions
ToStream
Writes the content of this JSON value to the given stream in.
- IOException
-
If an I/O error has occurred.