public static void ToJsonObjectFromDictionary <TKey>(IVOSJsonObject jobj, IDictionary <TKey, object> dct) { foreach (var item in dct) { jobj.AddField(item.Key.ToString(), item.Value.ToString()); } }
// // </ Array > // public static TValue FromJsonObjectToJobj <TValue>(IVOSJsonObject jobj) where TValue : IVOSJsonSirializable, new() { var val = new TValue(); val.DeserializeFromJson(jobj); return(val); }
public static void FromJsonObjectToDictionary(IVOSJsonObject jobj, IDictionary <string, int> dct) { string key = string.Empty; for (int i = 0; i < jobj.count; ++i) { key = jobj.GetKey(i); dct.Add(key, jobj.GetIntField(key)); } }
// // </ Dictionary > // // // < Collection > // public static void ToJsonArrayFromJobjCollection <TValue>(IVOSJsonArray jarr, ICollection <TValue> coll) where TValue : IVOSJsonSirializable { IVOSJsonObject jobj = null; foreach (var item in coll) { jobj = jarr.AddObjectItem(); item.SerializeToJson(jobj); } }
public static void ToJsonArrayFromJobjArray <TValue>(IVOSJsonArray jarr, TValue[] arr) where TValue : IVOSJsonSirializable { IVOSJsonObject jobj = null; for (int i = 0; i < arr.Length; ++i) { jobj = jarr.AddObjectItem(); arr[i].SerializeToJson(jobj); } }
// // < Dictionary > // public static void ToJsonObjectFromJobjDictionary <TKey, TValue>(IVOSJsonObject jobj, IDictionary <TKey, TValue> dct) where TValue : IVOSJsonSirializable { IVOSJsonObject jobjitem = null; foreach (var item in dct) { jobjitem = jobj.AddObjectField(item.Key.ToString()); item.Value.SerializeToJson(jobjitem); } }
public static void FromJsonArrayToJobjArray <TValue>(IVOSJsonArray jarr, TValue[] arr) where TValue : IVOSJsonSirializable, new() { TValue val = new TValue(); IVOSJsonObject jobj = null; for (int i = 0; i < jarr.count; ++i) { jobj = jarr.GetObjectItem(i); val = new TValue(); val.DeserializeFromJson(jobj); arr[i] = val; } }
// // </ Collection > // // // < Array > // public static void ToJsonArrayFromJobjArray <TValue>(IVOSJsonArray jarr, TValue[,] arr) where TValue : IVOSJsonSirializable { IVOSJsonArray rw = null; IVOSJsonObject jobj = null; for (int i = 0; i < arr.GetLength(0); ++i) { rw = jarr.AddArrayItem(); for (int j = 0; j < arr.GetLength(1); ++j) { jobj = rw.AddObjectItem(); arr[i, j].SerializeToJson(jobj); } } }
public static void FromJsonObjectToJobjDictionary <TValue>(IVOSJsonObject jobj, IDictionary <string, TValue> dct) where TValue : IVOSJsonSirializable, new() { TValue val = new TValue(); string key = string.Empty; for (int i = 0; i < jobj.count; ++i) { key = jobj.GetKey(i); val = new TValue(); val.DeserializeFromJson( jobj.GetObjectField(key)); dct.Add(key, val); } }
public static void FromJsonObjectToEnumDictionary <TEnum, TValue>(IVOSJsonObject jobj, IDictionary <TEnum, TValue> dct) where TValue : IVOSJsonSirializable, new() { TValue val = new TValue(); string key = string.Empty; for (int i = 0; i < jobj.count; ++i) { key = jobj.GetKey(i); val = new TValue(); val.DeserializeFromJson( jobj.GetObjectField(key)); dct.Add( (TEnum)System.Enum.Parse(typeof(TEnum), key), val); } }
public void DeserializeFromJson(IVOSJsonObject jobj) { denominator = jobj.GetIntField("Denominator"); numerator = jobj.GetIntField("Numerator"); }
public void SerializeToJson(IVOSJsonObject jobj) { jobj.AddField("Numerator", numerator); jobj.AddField("Denominator", denominator); }