Show / Hide Table of Contents

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 Source

AsArray()

The array value represented by the JSON value.

Declaration
IList<IJson> AsArray()
Returns
Type Description
IList<IJson>

The IList{IJson} this data represents, assuming it represents an array value.

Remarks

If IsArray() did not return true, then the behavior of this method is not well-defined.

| Improve this Doc View Source

AsBoolean()

The boolean value represented by the JSON value.

Declaration
bool AsBoolean()
Returns
Type Description
System.Boolean

The bool this data represents, assuming it represents a boolean value.

Remarks

If IsBoolean() did not return true, then the behavior of this method is not well-defined.

| Improve this Doc View Source

AsNumber()

The numeric value represented by the JSON value.

Declaration
double AsNumber()
Returns
Type Description
System.Double

The double this data represents, assuming it represents a numeric value.

Remarks

If IsNumber() did not return true, then the behavior of this method is not well-defined.

| Improve this Doc View Source

AsObject()

The object value represented by the JSON value.

Declaration
IDictionary<string, IJson> AsObject()
Returns
Type Description
IDictionary<System.String, IJson>

The IDictionary{string, IJson} this data represents, assuming it represents an object value.

Remarks

If IsObject() did not return true, then the behavior of this method is not well-defined.

| Improve this Doc View Source

AsString()

The string value represented by the JSON value.

Declaration
string AsString()
Returns
Type Description
System.String

The string this data represents, assuming it represents a string value.

Remarks

If IsString() did not return true, then the behavior of this method is not well-defined.

| Improve this Doc View Source

IsArray()

Whether the data represents a JSON array.

Declaration
bool IsArray()
Returns
Type Description
System.Boolean

true if the data represents a JSON array, false otherwise.

| Improve this Doc View Source

IsBoolean()

Whether the data represents JSON true or false.

Declaration
bool IsBoolean()
Returns
Type Description
System.Boolean

true if the data represents JSON true or false, false otherwise.

| Improve this Doc View Source

IsNull()

Whether the data represents JSON null.

Declaration
bool IsNull()
Returns
Type Description
System.Boolean

true if the data represents JSON null, false otherwise.

| Improve this Doc View Source

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

true if the data represents a JSON number, false otherwise.

| Improve this Doc View Source

IsObject()

Whether the data represents a JSON object.

Declaration
bool IsObject()
Returns
Type Description
System.Boolean

true if the data represents a JSON object, false otherwise.

| Improve this Doc View Source

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

true if the data represents a JSON string, false otherwise.

See Also

NewtonsoftAdapter
SystemTextAdapter
  • Improve this Doc
  • View Source
Back to top Generated by DocFX