diff --git a/src/LitJson/IJsonWrapper.cs b/src/LitJson/IJsonWrapper.cs index 9b7e2d1..b4d90cf 100644 --- a/src/LitJson/IJsonWrapper.cs +++ b/src/LitJson/IJsonWrapper.cs @@ -42,6 +42,7 @@ public interface IJsonWrapper : IList, IOrderedDictionary bool GetBoolean (); double GetDouble (); + double[] GetDoubleArray (); int GetInt (); JsonType GetJsonType (); long GetLong (); diff --git a/src/LitJson/JsonData.cs b/src/LitJson/JsonData.cs index 975308d..98dee6c 100644 --- a/src/LitJson/JsonData.cs +++ b/src/LitJson/JsonData.cs @@ -536,6 +536,34 @@ double IJsonWrapper.GetDouble () return inst_double; } + double[] IJsonWrapper.GetDoubleArray () + { + if (type != JsonType.Array) + { + throw new InvalidOperationException ( + "JsonData instance doesn't hold a array"); + } + + if (inst_array.Count > 0) + { + if (!(inst_array[0] as IJsonWrapper).IsDouble) + { + throw new InvalidOperationException ( + "JsonData instance doesn't hold a double[]"); + } + + double[] array = new double[inst_array.Count]; + for (int i = 0; i < inst_array.Count; i++) + { + array[i] = (inst_array[i] as IJsonWrapper).GetDouble (); + } + + return array; + } + + return new double[0]; + } + int IJsonWrapper.GetInt () { if (type != JsonType.Int)