We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
The text was updated successfully, but these errors were encountered:
here's a real world example of the output: ], "connections": "camerapositionX" : "0", "camerapositionY": "0",
], "connections": "camerapositionX" : "0", "camerapositionY": "0",
connections should be [] but i'd be ok with null but its blank.
Sorry, something went wrong.
Fixed by #115
No branches or pull requests
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());
}
}
error is
Unable to wrap ... with JsonData
The text was updated successfully, but these errors were encountered: