BGC Tools
Data Structures | Public Member Functions | Data Fields | Properties | Private Member Functions | Private Attributes
LightJson.JsonObject Class Reference

Represents a key-value pair collection of JsonValue objects. More...

Inheritance diagram for LightJson.JsonObject:
Inheritance graph
[legend]
Collaboration diagram for LightJson.JsonObject:
Collaboration graph
[legend]

Data Structures

class  JsonObjectDebugView
 

Public Member Functions

 JsonObject ()
 Initializes a new instance of JsonObject. More...
 
JsonObject Add (string key)
 Adds a key with a null value to this collection. More...
 
JsonObject Add (string key, JsonValue value)
 Adds a value associated with a key to this collection. More...
 
JsonObject AddIfNotNull (string key, JsonValue value)
 Adds a value associated with a key to this collection only if the value is not null. More...
 
bool Remove (string key)
 Removes a property with the given key. More...
 
JsonObject Clear ()
 Clears the contents of this collection. More...
 
JsonObject Rename (string oldKey, string newKey)
 Changes the key of one of the items in the collection. More...
 
bool ContainsKey (string key)
 Determines whether this collection contains an item assosiated with the given key. More...
 
bool ContainsKey (string key, out JsonValue value)
 Determines whether this collection contains an item assosiated with the given key. More...
 
bool Contains (JsonValue value)
 Determines whether this collection contains the given JsonValue. More...
 
IEnumerator< KeyValuePair< string, JsonValue > > GetEnumerator ()
 Returns an enumerator that iterates through this collection. More...
 
override string ToString ()
 Returns a JSON string representing the state of the object. More...
 
string ToString (bool pretty)
 Returns a JSON string representing the state of the object. More...
 

Data Fields

int Count => properties.Count
 The number of properties in this JsonObject. More...
 

Properties

JsonValue this[string key] [get, set]
 The property with the given key. More...
 

Private Member Functions

IEnumerator< JsonValue > IEnumerable< JsonValue >. GetEnumerator ()
 Returns an enumerator that iterates through this collection. More...
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 Returns an enumerator that iterates through this collection. More...
 

Private Attributes

Dictionary< string, JsonValueproperties = new Dictionary<string, JsonValue>()
 

Detailed Description

Represents a key-value pair collection of JsonValue objects.

Definition at line 13 of file JsonObject.cs.

Constructor & Destructor Documentation

◆ JsonObject()

LightJson.JsonObject.JsonObject ( )
inline

Initializes a new instance of JsonObject.

Definition at line 45 of file JsonObject.cs.

References LightJson.JsonObject.Add(), and LightJson.JsonValue.Null.

45 { }
Here is the call graph for this function:

Member Function Documentation

◆ Add() [1/2]

JsonObject LightJson.JsonObject.Add ( string  key)

◆ Add() [2/2]

JsonObject LightJson.JsonObject.Add ( string  key,
JsonValue  value 
)
inline

Adds a value associated with a key to this collection.

Parameters
keyThe key of the property to be added.
valueThe value of the property to be added.
Returns
Returns this JsonObject.

Definition at line 60 of file JsonObject.cs.

References LightJson.JsonObject.Add().

61  {
62  properties.Add(key, value);
63  return this;
64  }
Dictionary< string, JsonValue > properties
Definition: JsonObject.cs:15
Here is the call graph for this function:

◆ AddIfNotNull()

JsonObject LightJson.JsonObject.AddIfNotNull ( string  key,
JsonValue  value 
)
inline

Adds a value associated with a key to this collection only if the value is not null.

Parameters
keyThe key of the property to be added.
valueThe value of the property to be added.
Returns
Returns this JsonObject.

Definition at line 72 of file JsonObject.cs.

References LightJson.JsonObject.Add(), LightJson.JsonValue.IsNull, and LightJson.JsonObject.Remove().

73  {
74  if (value.IsNull == false)
75  {
76  Add(key, value);
77  }
78 
79  return this;
80  }
JsonObject Add(string key)
Adds a key with a null value to this collection.
Here is the call graph for this function:

◆ Clear()

JsonObject LightJson.JsonObject.Clear ( )
inline

Clears the contents of this collection.

Returns
Returns this JsonObject.

Definition at line 95 of file JsonObject.cs.

References LightJson.JsonObject.Clear().

Referenced by BGC.Users.ProfileData.Clear(), and LightJson.JsonObject.Clear().

96  {
97  properties.Clear();
98  return this;
99  }
Dictionary< string, JsonValue > properties
Definition: JsonObject.cs:15
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Contains()

bool LightJson.JsonObject.Contains ( JsonValue  value)

Determines whether this collection contains the given JsonValue.

Parameters
valueThe value to locate in this collection.
Returns
Returns true if the value is found; otherwise, false.

Referenced by LightJson.JsonObject.Rename().

Here is the caller graph for this function:

◆ ContainsKey() [1/2]

bool LightJson.JsonObject.ContainsKey ( string  key)

◆ ContainsKey() [2/2]

bool LightJson.JsonObject.ContainsKey ( string  key,
out JsonValue  value 
)

Determines whether this collection contains an item assosiated with the given key.

Parameters
keyThe key to locate in this collection.
valueWhen this method returns, this value gets assigned the JsonValue assosiated with the key, if the key is found; otherwise, JsonValue.Null is assigned.
Returns
Returns true if the key is found; otherwise, false.

◆ GetEnumerator() [1/3]

IEnumerator<KeyValuePair<string, JsonValue> > LightJson.JsonObject.GetEnumerator ( )

Returns an enumerator that iterates through this collection.

Referenced by LightJson.Serialization.JsonWriter.GetJsonObjectEnumerator(), and LightJson.JsonObject.Rename().

Here is the caller graph for this function:

◆ GetEnumerator() [2/3]

IEnumerator<JsonValue> IEnumerable<JsonValue>. LightJson.JsonObject.GetEnumerator ( )
private

Returns an enumerator that iterates through this collection.

◆ GetEnumerator() [3/3]

System.Collections.IEnumerator System.Collections.IEnumerable. LightJson.JsonObject.GetEnumerator ( )
private

Returns an enumerator that iterates through this collection.

◆ Remove()

bool LightJson.JsonObject.Remove ( string  key)

Removes a property with the given key.

Parameters
keyThe key of the property to be removed.
Returns
Returns true if the given key is found and removed; otherwise, false.

Referenced by LightJson.JsonObject.AddIfNotNull(), BGC.Users.ProfileData.GetJsonArray(), BGC.Study.ProtocolManager.RemoveRedundancies(), and LightJson.JsonObject.Rename().

Here is the caller graph for this function:

◆ Rename()

JsonObject LightJson.JsonObject.Rename ( string  oldKey,
string  newKey 
)
inline

Changes the key of one of the items in the collection.

This method has no effects if the oldKey does not exists. If the newKey already exists, the value will be overwritten.

Parameters
oldKeyThe name of the key to be changed.
newKeyThe new name of the key.
Returns
Returns this JsonObject.

Definition at line 111 of file JsonObject.cs.

References LightJson.JsonObject.Contains(), LightJson.JsonObject.ContainsKey(), LightJson.JsonObject.GetEnumerator(), LightJson.JsonObject.Remove(), LightJson.Serialization.JsonWriter.Serialize(), and LightJson.JsonObject.ToString().

112  {
113  JsonValue value;
114 
115  if (properties.TryGetValue(oldKey, out value))
116  {
117  Remove(oldKey);
118  this[newKey] = value;
119  }
120 
121  return this;
122  }
bool Remove(string key)
Removes a property with the given key.
Dictionary< string, JsonValue > properties
Definition: JsonObject.cs:15
Here is the call graph for this function:

◆ ToString() [1/2]

override string LightJson.JsonObject.ToString ( )

Returns a JSON string representing the state of the object.

The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.

Referenced by BGC.Study.ProtocolManager.RemoveRedundancies(), and LightJson.JsonObject.Rename().

Here is the caller graph for this function:

◆ ToString() [2/2]

string LightJson.JsonObject.ToString ( bool  pretty)

Returns a JSON string representing the state of the object.

The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.

Parameters
prettyIndicates whether the resulting string should be formatted for human-readability.

Field Documentation

◆ Count

int LightJson.JsonObject.Count => properties.Count

◆ properties

Dictionary<string, JsonValue> LightJson.JsonObject.properties = new Dictionary<string, JsonValue>()
private

Definition at line 15 of file JsonObject.cs.

Property Documentation

◆ this[string key]

JsonValue LightJson.JsonObject.this[string key]
getset

The property with the given key.

Parameters
keyThe key of the property to get or set.

Returns JsonValue.Null if the given key is not assosiated with any value.

Definition at line 24 of file JsonObject.cs.


The documentation for this class was generated from the following file: