JSONFormatter Class |
Namespace: Telogis.GeoBase.Serialization
The JSONFormatter type exposes the following members.
Name | Description | |
---|---|---|
DeserializeT |
Deserializes a given string into an object that implements IJSONSerializable.
| |
Serialize(IJSONSerializable) |
Serializes a IJSONSerializable into a string.
| |
Serialize(JSONObject) |
Serializes a JSONObject into a string.
|
class Item : IJSONSerializable { public int Value { get; set; } public string JSONName { get { return "Item"; } } public JSONObject ToJSON() { JSONObject formatter = new JSONObject(); formatter["value"] = Value; return formatter; } public void FromJSON(JSONObject source) { Value = source.Get<int>("value", 0); } } public static int Main(string[] args) { Item originalItem = new Item { Value = 2 }; string jsonString = JSONFormatter.Serialize(originalItem); Item item = JSONFormatter.Deserialize<Item>(jsonString); }