Interface IJson
Interface IJson represents the JSON data model.
Namespace: Jtd.Jtd
Assembly: Jtd.Jtd.dll
Syntax
public interface IJson
Remarks
In the CSharp ecosystem, the two primary JSON implementations,
Newtonsoft.Json and System.Text.Json, have mutually
incompatible representations of arbitrary JSON data. This interface
exists to unify these data models, and to support other JSON
implementations.
Methods
| Improve this Doc View SourceAsArray()
The array value represented by the JSON value.
Declaration
IList<IJson> AsArray()
Returns
| Type | Description |
|---|---|
| IList<IJson> | The |
Remarks
If IsArray() did not return true, then the
behavior of this method is not well-defined.
AsBoolean()
The boolean value represented by the JSON value.
Declaration
bool AsBoolean()
Returns
| Type | Description |
|---|---|
| System.Boolean | The |
Remarks
If IsBoolean() did not return true, then the
behavior of this method is not well-defined.
AsNumber()
The numeric value represented by the JSON value.
Declaration
double AsNumber()
Returns
| Type | Description |
|---|---|
| System.Double | The |
Remarks
If IsNumber() did not return true, then the
behavior of this method is not well-defined.
AsObject()
The object value represented by the JSON value.
Declaration
IDictionary<string, IJson> AsObject()
Returns
| Type | Description |
|---|---|
| IDictionary<System.String, IJson> | The |
Remarks
If IsObject() did not return true, then the
behavior of this method is not well-defined.
AsString()
The string value represented by the JSON value.
Declaration
string AsString()
Returns
| Type | Description |
|---|---|
| System.String | The |
Remarks
If IsString() did not return true, then the
behavior of this method is not well-defined.
IsArray()
Whether the data represents a JSON array.
Declaration
bool IsArray()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsBoolean()
Whether the data represents JSON true or false.
Declaration
bool IsBoolean()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsNull()
Whether the data represents JSON null.
Declaration
bool IsNull()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsNumber()
Whether the data represents a JSON number. This includes "integers"
(e.g. 3), "floating-point numbers" (e.g. 3.14), and
"exponential numbers" (e.g. 3.14e5).
Declaration
bool IsNumber()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsObject()
Whether the data represents a JSON object.
Declaration
bool IsObject()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsString()
Whether the data represents a JSON string. This includes strings that happen to represent timestamps, UUIDs, GUIDs, URLs, or other data commonly represented as strings in JSON.
Declaration
bool IsString()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|