Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/LitJson/IJsonWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public interface IJsonWrapper : IList, IOrderedDictionary

bool GetBoolean ();
double GetDouble ();
double[] GetDoubleArray ();
int GetInt ();
JsonType GetJsonType ();
long GetLong ();
Expand Down
28 changes: 28 additions & 0 deletions src/LitJson/JsonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down