Class GenericJsonData
[Serializable]
[JsonObject]
public class GenericJsonData
Inherited Members
Namespace: HomeSeer.PluginSdk.Features
Assembly: PluginSdk.dll
Generic data collection used as a JSON object. Takes the form of {"data":{}}. See JsonRequest, JsonResponse, and JsonError for basic implementation
Constructors
View SourceGenericJsonData()
Create a new GenericJsonData object
Declaration
[JsonConstructor]
public GenericJsonData()
GenericJsonData(Dictionary<String, String>)
Create a new GenericJsonData object with data
Declaration
public GenericJsonData(Dictionary<string, string> data)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | data |
Properties
View SourceData
A collection of data keys and values
Declaration
[JsonProperty("data")]
public Dictionary<string, string> Data { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
Methods
View SourceClear()
Remove all data from the collection
Declaration
public void Clear()
Contains(String)
Determine if a key exists in the data collection
Declaration
public bool Contains(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to look for |
Returns
Type | Description |
---|---|
System.Boolean | TRUE if the key exists in the collection, FALSE if it does not |
FromJson(String)
Deserialize a GenericJsonData object from JSON
Declaration
public static GenericJsonData FromJson(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | JSON string containing a serialized GenericJsonData |
Returns
Type | Description |
---|---|
GenericJsonData | A GenericJsonData object |
Get(String)
Get the data value for a key
Declaration
public string Get(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key for the data to get |
Returns
Type | Description |
---|---|
System.String | The data value corresponding to the key |
Put(String, String)
Put a value in the data collection
Declaration
public void Put(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to map the data with |
System.String | value | The data value to save |
Remove(String)
Remove the value associated with a key from the data
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to remove from the data |
ToJson()
Serialize the data to a JSON string
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String | A JSON string |