Skip to content

JsonValue

Marcos López C edited this page Apr 6, 2024 · 2 revisions

Overview

LightJson.JsonValue is a struct in the LightJson library, designed to represent a JSON value. It encapsulates various JSON data types such as null, boolean, number, string, object, and array.

Constructors

  • public JsonValue(bool? value)
    Initializes a new instance of the JsonValue struct, representing a boolean value.

  • public JsonValue(double? value)
    Initializes a new instance of the JsonValue struct, representing a number value.

  • public JsonValue(string value)
    Initializes a new instance of the JsonValue struct, representing a string value.

  • public JsonValue(JsonObject value)
    Initializes a new instance of the JsonValue struct, representing a JsonObject value.

  • public JsonValue(JsonArray value)
    Initializes a new instance of the JsonValue struct, representing a JsonArray value.

Properties

  • public JsonValueType Type { get; }
    Gets the type of this JsonValue.

  • public bool IsNull { get; }
    Gets a value indicating whether this JsonValue is null.

  • public bool IsBoolean { get; }
    Gets a value indicating whether this JsonValue represents a boolean value.

  • public bool IsInteger { get; }
    Gets a value indicating whether this JsonValue represents an integer value.

  • public bool IsNumber { get; }
    Gets a value indicating whether this JsonValue represents a number.

  • public bool IsString { get; }
    Gets a value indicating whether this JsonValue represents a string.

  • public bool IsJsonObject { get; }
    Gets a value indicating whether this JsonValue is a JsonObject.

  • public bool IsJsonArray { get; }
    Gets a value indicating whether this JsonValue is a JsonArray.

  • public bool IsDateTime { get; }
    Gets a value indicating whether this JsonValue represents a DateTime.

Methods

  • public JsonValue Parse(string text)
    Returns a JsonValue by parsing the given string.

Operators

  • == Operator
    Returns a value indicating whether the two given JsonValue instances are equal.

  • != Operator
    Returns a value indicating whether the two given JsonValue instances are unequal.

Implicit Conversions

The JsonValue struct provides implicit conversion operators for various data types such as bool, int, double, string, JsonObject, JsonArray, and DateTime.

Remarks

JsonValue stores DateTime values as strings using ISO 8601 format since JSON does not define a DateTime type. The struct provides methods and operators for easy conversion between JSON data types and .NET data types. JsonValue is lightweight and designed for efficient handling of JSON data.

Clone this wiki locally