From e06bc2e96039c68731ef267b28416391e65d212a Mon Sep 17 00:00:00 2001 From: shinriyo Date: Fri, 23 May 2014 18:55:13 +0900 Subject: [PATCH 1/2] GetDoubleArray() we hope just get double[]. later I will add int[] too --- src/LitJson/IJsonWrapper.cs | 1 + 1 file changed, 1 insertion(+) 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 (); From 3a480fc8f7429ef50e6cba70e1e0871173309a0f Mon Sep 17 00:00:00 2001 From: shinriyo Date: Fri, 23 May 2014 18:56:09 +0900 Subject: [PATCH 2/2] GetDoubleArray () It is useful --- src/LitJson/JsonData.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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)