-
-
Notifications
You must be signed in to change notification settings - Fork 403
Closed
Description
It seems this has been a problem since 2014.
LitJson does not handle empty lists or arrays as a new JsonData object or as an addition to an existing JsonData object.
These 4 tests in Unity all fail.
using UnityEngine;
using LitJson;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
namespace DefaultNamespace
{
public class TestLitJsonArray : MonoBehaviour
{
[MenuItem("Window/TestLitJsonList")]
static void doTest1()
{
List strings = new List();
JsonData jd = new JsonData();
jd.Add(strings);
File.WriteAllText(Application.streamingAssetsPath+("/arrayTest1.json"),jd.ToJson());
}
[MenuItem("Window/TestLitJsonList2")]
static void doTest2()
{
List<string> strings = new List<string>();
JsonData jd = new JsonData(strings);
File.WriteAllText(Application.streamingAssetsPath+("/arrayTest2.json"),jd.ToJson());
}
[MenuItem("Window/TestLitJsonArray")]
static void doTest3()
{
string[] strings2 = new string[1]; // Im trying to write a 0 length array, it errors if this is 1 or 0
JsonData jd = new JsonData();
jd.Add(strings2);
File.WriteAllText(Application.streamingAssetsPath+("/arrayTest3.json"),jd.ToJson());
}
[MenuItem("Window/TestLitJsonArray2")]
static void doTest4()
{
string[] strings2 = new string[1];
JsonData jd = new JsonData(strings2);
File.WriteAllText(Application.streamingAssetsPath+("/arrayTest4.json"), jd.ToJson());
}
}
}
error is
Unable to wrap ... with JsonData
Reactions are currently unavailable