IntelligenceX
Class

JsonObject

Namespace IntelligenceX.Json
Assembly IntelligenceX
Implements
IEnumerable<KeyValuePair<String, JsonValue>> IEnumerable
Modifiers sealed
Attributes
DefaultMember("Item")

Represents a mutable JSON object.

Inheritance

  • Object
  • JsonObject

Constructors

JsonObject 2 overloads
public JsonObject() #

Initializes an empty JSON object with ordinal key comparison.

public JsonObject(StringComparer comparer) #

Initializes an empty JSON object with a custom key comparer.

Parameters

comparer System.StringComparer
Comparer used for key lookup.

Methods

Add 7 overloads
public JsonObject Add(String key, JsonArray value) #
Returns: JsonObject

Adds or replaces a JSON value for the specified key.

Parameters

key System.String
value IntelligenceX.Json.JsonValue
public JsonObject Add(String key, String value) #
Returns: JsonObject

Adds or replaces a string value for the specified key.

Parameters

key System.String
value System.String
public JsonObject Add(String key, Boolean value) #
Returns: JsonObject

Adds or replaces a boolean value for the specified key.

Parameters

key System.String
value System.Boolean
public JsonObject Add(String key, Int64 value) #
Returns: JsonObject

Adds or replaces an integer value for the specified key.

Parameters

key System.String
value System.Int64
public JsonObject Add(String key, Double value) #
Returns: JsonObject

Adds or replaces a double value for the specified key.

Parameters

key System.String
value System.Double
Add(System.String key, IntelligenceX.Json.JsonObject value) #

Adds or replaces a JSON object value for the specified key.

Parameters

key System.String
value IntelligenceX.Json.JsonObject
Add(System.String key, IntelligenceX.Json.JsonArray value) #

Adds or replaces a JSON array value for the specified key.

Parameters

key System.String
value IntelligenceX.Json.JsonArray
public JsonArray GetArray(String key) #
Returns: JsonArray

Returns a JSON array value for the specified key.

Parameters

key System.String
public Boolean GetBoolean(String key, Boolean defaultValue = false) #
Returns: Boolean

Returns a boolean value for the specified key or a default when missing.

Parameters

key System.String
defaultValue System.Boolean = false
public Nullable<Double> GetDouble(String key) #
Returns: Nullable<Double>

Returns a double value for the specified key.

Parameters

key System.String
public virtual IEnumerator<KeyValuePair<String, JsonValue>> GetEnumerator() #
Returns: IEnumerator<KeyValuePair<String, JsonValue>>

Returns a typed enumerator over the object's properties.

public Nullable<Int64> GetInt64(String key) #
Returns: Nullable<Int64>

Returns an integer value for the specified key.

Parameters

key System.String
public JsonObject GetObject(String key) #
Returns: JsonObject

Returns a JSON object value for the specified key.

Parameters

key System.String
public String GetString(String key) #
Returns: String

Returns a string value for the specified key.

Parameters

key System.String
System#Collections#IEnumerable#GetEnumerator() #

Returns a non-generic enumerator over the object's properties.

public Boolean TryGetValue(String key, out JsonValue value) #
Returns: Boolean

Attempts to retrieve a JSON value by key.

Parameters

key System.String
value IntelligenceX.Json.JsonValue@

Properties

public Int32 Count { get; } #

Gets the number of properties in the object.

public JsonValue Item { get; set; } #

Gets or sets a value by property key.

Extension Methods

public static JsonObject ExtractAdditional(JsonObject obj, params String[] knownKeys) #
Returns: JsonObject

Returns a new object containing properties that are not in knownKeys.

Parameters

obj IntelligenceX.Json.JsonObject
Source JSON object.
knownKeys System.String[]
Keys to exclude from the result.

Returns

A new object containing unknown keys, or null when none exist.