Browse Source

Update JSONObject

Replaced with newer version
Close #810
master
shalliwell 5 years ago
parent
commit
c8d41a02b4
  1. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor.meta
  2. 103
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor/JSONChecker.cs
  3. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor/JSONChecker.cs.meta
  4. 202
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/JSONObject.cs
  5. 19
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/LICENSE.md
  6. 7
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/LICENSE.md.meta
  7. 211
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/VectorTemplates.cs
  8. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/VectorTemplates.cs.meta
  9. 192
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.md
  10. 7
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.md.meta
  11. 188
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.txt
  12. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.txt.meta

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor.meta vendored

@ -0,0 +1,2 @@
fileFormatVersion: 1
guid: 6b700d54458b2824c934e039a95c468c

103
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor/JSONChecker.cs vendored

@ -0,0 +1,103 @@
//#define PERFTEST //For testing performance of parse/stringify. Turn on editor profiling to see how we're doing
using UnityEngine;
using UnityEditor;
#if UNITY_2017_1_OR_NEWER
using UnityEngine.Networking;
#endif
/*
Copyright (c) 2010-2019 Matt Schoen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
public class JSONChecker : EditorWindow {
string JSON = @"{
""TestObject"": {
""SomeText"": ""Blah"",
""SomeObject"": {
""SomeNumber"": 42,
""SomeFloat"": 13.37,
""SomeBool"": true,
""SomeNull"": null
},
""SomeEmptyObject"": { },
""SomeEmptyArray"": [ ],
""EmbeddedObject"": ""{\""field\"":\""Value with \\\""escaped quotes\\\""\""}""
}
}"; //dat string literal...
string URL = "";
JSONObject j;
[MenuItem("Window/JSONChecker")]
static void Init() {
GetWindow(typeof(JSONChecker));
}
void OnGUI() {
JSON = EditorGUILayout.TextArea(JSON);
GUI.enabled = !string.IsNullOrEmpty(JSON);
if(GUILayout.Button("Check JSON")) {
#if PERFTEST
Profiler.BeginSample("JSONParse");
j = JSONObject.Create(JSON);
Profiler.EndSample();
Profiler.BeginSample("JSONStringify");
j.ToString(true);
Profiler.EndSample();
#else
j = JSONObject.Create(JSON);
#endif
Debug.Log(j.ToString(true));
}
EditorGUILayout.Separator();
URL = EditorGUILayout.TextField("URL", URL);
if (GUILayout.Button("Get JSON")) {
Debug.Log(URL);
#if UNITY_2017_1_OR_NEWER
var test = new UnityWebRequest(URL);
test.SendWebRequest();
while (!test.isDone && !test.isNetworkError) ;
#else
var test = new WWW(URL);
while (!test.isDone) ;
#endif
if (!string.IsNullOrEmpty(test.error)) {
Debug.Log(test.error);
} else {
#if UNITY_2017_1_OR_NEWER
var text = test.downloadHandler.text;
#else
var text = test.text;
#endif
Debug.Log(text);
j = new JSONObject(text);
Debug.Log(j.ToString(true));
}
}
if(j) {
//Debug.Log(System.GC.GetTotalMemory(false) + "");
if(j.type == JSONObject.Type.NULL)
GUILayout.Label("JSON fail:\n" + j.ToString(true));
else
GUILayout.Label("JSON success:\n" + j.ToString(true));
}
}
}

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/Editor/JSONChecker.cs.meta vendored

@ -0,0 +1,2 @@
fileFormatVersion: 1
guid: 6c5a625d29393ed4da8d9150a629fb35

202
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/JSONObject.cs vendored

@ -1,12 +1,9 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#define PRETTY //Comment out when you no longer need to read JSON to disable pretty Print system-wide
//Using doubles will cause errors in VectorTemplates.cs; Unity speaks floats
#define USEFLOAT //Use floats for numbers instead of doubles (enable if you're getting too many significant digits in string output)
//#define POOLING //Currently using a build setting for this one (also it's experimental)
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
using UnityEngine;
using Debug = UnityEngine.Debug;
#endif
@ -14,19 +11,30 @@ using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using MoonSharp.Interpreter.Diagnostics.PerformanceCounters;
using System.Globalization;
/*
* http://www.opensource.org/licenses/lgpl-2.1.php
* JSONObject class v.1.4.1
* for use with Unity
* Copyright Matt Schoen 2010 - 2013
*/
Copyright (c) 2010-2019 Matt Schoen
// Added to Fungus namespace to minimize conflicts with other assets
namespace Fungus
{
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
public class JSONObject {
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
public class JSONObject : IEnumerable {
#if POOLING
const int MAX_POOL_SIZE = 10000;
public static Queue<JSONObject> releaseQueue = new Queue<JSONObject>();
@ -229,10 +237,10 @@ public class JSONObject {
/// Create a JSONObject by parsing string data
/// </summary>
/// <param name="val">The string to be parsed</param>
/// <param name="maxDepth">The maximum depth for the parser to search. Set this to to 1 for the first level,
/// <param name="maxDepth">The maximum depth for the parser to search. Set this to to 1 for the first level,
/// 2 for the first 2 levels, etc. It defaults to -2 because -1 is the depth value that is parsed (see below)</param>
/// <param name="storeExcessLevels">Whether to store levels beyond maxDepth in baked JSONObjects</param>
/// <param name="strict">Whether to be strict in the parsing. For example, non-strict parsing will successfully
/// <param name="strict">Whether to be strict in the parsing. For example, non-strict parsing will successfully
/// parse "a string" into a string-type </param>
/// <returns></returns>
public static JSONObject Create(string val, int maxDepth = -2, bool storeExcessLevels = false, bool strict = false) {
@ -268,7 +276,7 @@ public class JSONObject {
if(strict) {
if(str[0] != '[' && str[0] != '{') {
type = Type.NULL;
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.LogWarning
#else
Debug.WriteLine
@ -346,18 +354,18 @@ public class JSONObject {
default:
try {
#if USEFLOAT
n = System.Convert.ToSingle(str);
n = System.Convert.ToSingle(str, CultureInfo.InvariantCulture);
#else
n = System.Convert.ToDouble(str);
n = System.Convert.ToDouble(str, CultureInfo.InvariantCulture);
#endif
if(!str.Contains(".")) {
i = System.Convert.ToInt64(str);
i = System.Convert.ToInt64(str, CultureInfo.InvariantCulture);
useInt = true;
}
type = Type.NUMBER;
} catch(System.FormatException) {
type = Type.NULL;
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.LogWarning
#else
Debug.WriteLine
@ -410,7 +418,7 @@ public class JSONObject {
if(type == Type.OBJECT)
keys.Add(propName);
if(maxDepth != -1) //maxDepth of -1 is the end of the line
list.Add(Create(inner, (maxDepth < -1) ? -2 : maxDepth - 1));
list.Add(Create(inner, (maxDepth < -1) ? -2 : maxDepth - 1, storeExcessLevels));
else if(storeExcessLevels)
list.Add(CreateBakedObject(inner));
@ -436,6 +444,9 @@ public class JSONObject {
public void Add(float val) {
Add(Create(val));
}
public void Add(long val) {
Add(Create(val));
}
public void Add(int val) {
Add(Create(val));
}
@ -480,7 +491,7 @@ public class JSONObject {
keys = new List<string>();
if(type == Type.ARRAY) {
for(int i = 0; i < list.Count; i++)
keys.Add(i + "");
keys.Add(i.ToString(CultureInfo.InvariantCulture));
} else
if(list == null)
list = new List<JSONObject>();
@ -493,6 +504,7 @@ public class JSONObject {
public void SetField(string name, string val) { SetField(name, CreateStringObject(val)); }
public void SetField(string name, bool val) { SetField(name, Create(val)); }
public void SetField(string name, float val) { SetField(name, Create(val)); }
public void SetField(string name, long val) { SetField(name, Create(val)); }
public void SetField(string name, int val) { SetField(name, Create(val)); }
public void SetField(string name, JSONObject obj) {
if(HasField(name)) {
@ -555,7 +567,7 @@ public class JSONObject {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (int)list[index].n;
field = (int)list[index].i;
return true;
}
}
@ -570,7 +582,7 @@ public class JSONObject {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (long)list[index].n;
field = (long)list[index].i;
return true;
}
}
@ -585,7 +597,7 @@ public class JSONObject {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (uint)list[index].n;
field = (uint)list[index].i;
return true;
}
}
@ -688,7 +700,7 @@ public class JSONObject {
}
} else if(left.type == Type.ARRAY && right.type == Type.ARRAY) {
if(right.Count > left.Count) {
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.LogError
#else
Debug.WriteLine
@ -733,11 +745,9 @@ public class JSONObject {
}
public IEnumerable<string> PrintAsync(bool pretty = false) {
StringBuilder builder = new StringBuilder();
#if !NETFX_CORE
printWatch.Reset();
printWatch.Reset();
printWatch.Start();
#endif
foreach(IEnumerable e in StringifyAsync(0, builder, pretty)) {
foreach(IEnumerable e in StringifyAsync(0, builder, pretty)) {
yield return null;
}
yield return builder.ToString();
@ -749,7 +759,7 @@ public class JSONObject {
IEnumerable StringifyAsync(int depth, StringBuilder builder, bool pretty = false) { //Convert the JSONObject into a string
//Profiler.BeginSample("JSONprint");
if(depth++ > MAX_DEPTH) {
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.Log
#else
Debug.WriteLine
@ -757,16 +767,12 @@ public class JSONObject {
("reached max depth!");
yield break;
}
#if !NETFX_CORE
if(printWatch.Elapsed.TotalSeconds > maxFrameTime) {
printWatch.Reset();
yield return null;
printWatch.Start();
}
#endif
switch(type) {
switch(type) {
case Type.BAKED:
builder.Append(str);
break;
@ -775,7 +781,7 @@ public class JSONObject {
break;
case Type.NUMBER:
if(useInt) {
builder.Append(i.ToString());
builder.Append(i.ToString(CultureInfo.InvariantCulture));
} else {
#if USEFLOAT
if(float.IsInfinity(n))
@ -793,13 +799,13 @@ public class JSONObject {
builder.Append(NaN);
#endif
else
builder.Append(n.ToString());
builder.Append(n.ToString(CultureInfo.InvariantCulture));
}
break;
case Type.OBJECT:
builder.Append("{");
if(list.Count > 0) {
#if (PRETTY) //for a bit more readability, comment the define above to disable system-wide
#if(PRETTY) //for a bit more readability, comment the define above to disable system-wide
if(pretty)
builder.Append(NEWLINE);
#endif
@ -807,7 +813,7 @@ public class JSONObject {
string key = keys[i];
JSONObject obj = list[i];
if(obj) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
for(int j = 0; j < depth; j++)
builder.Append("\t"); //for a bit more readability
@ -816,20 +822,20 @@ public class JSONObject {
foreach(IEnumerable e in obj.StringifyAsync(depth, builder, pretty))
yield return e;
builder.Append(",");
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append(NEWLINE);
#endif
}
}
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Length -= 2;
else
#endif
builder.Length--;
}
#if (PRETTY)
#if(PRETTY)
if(pretty && list.Count > 0) {
builder.Append(NEWLINE);
for(int j = 0; j < depth - 1; j++)
@ -841,13 +847,13 @@ public class JSONObject {
case Type.ARRAY:
builder.Append("[");
if(list.Count > 0) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append(NEWLINE); //for a bit more readability
#endif
for(int i = 0; i < list.Count; i++) {
if(list[i]) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
for(int j = 0; j < depth; j++)
builder.Append("\t"); //for a bit more readability
@ -855,20 +861,20 @@ public class JSONObject {
foreach(IEnumerable e in list[i].StringifyAsync(depth, builder, pretty))
yield return e;
builder.Append(",");
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append(NEWLINE); //for a bit more readability
#endif
}
}
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Length -= 2;
else
#endif
builder.Length--;
}
#if (PRETTY)
#if(PRETTY)
if(pretty && list.Count > 0) {
builder.Append(NEWLINE);
for(int j = 0; j < depth - 1; j++)
@ -899,7 +905,7 @@ public class JSONObject {
void Stringify(int depth, StringBuilder builder, bool pretty = false) { //Convert the JSONObject into a string
//Profiler.BeginSample("JSONprint");
if(depth++ > MAX_DEPTH) {
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.Log
#else
Debug.WriteLine
@ -916,7 +922,7 @@ public class JSONObject {
break;
case Type.NUMBER:
if(useInt) {
builder.Append(i.ToString());
builder.Append(i.ToString(CultureInfo.InvariantCulture));
} else {
#if USEFLOAT
if(float.IsInfinity(n))
@ -934,13 +940,13 @@ public class JSONObject {
builder.Append(NaN);
#endif
else
builder.Append(n.ToString());
builder.Append(n.ToString(CultureInfo.InvariantCulture));
}
break;
case Type.OBJECT:
builder.Append("{");
if(list.Count > 0) {
#if (PRETTY) //for a bit more readability, comment the define above to disable system-wide
#if(PRETTY) //for a bit more readability, comment the define above to disable system-wide
if(pretty)
builder.Append("\n");
#endif
@ -948,7 +954,7 @@ public class JSONObject {
string key = keys[i];
JSONObject obj = list[i];
if(obj) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
for(int j = 0; j < depth; j++)
builder.Append("\t"); //for a bit more readability
@ -956,20 +962,20 @@ public class JSONObject {
builder.AppendFormat("\"{0}\":", key);
obj.Stringify(depth, builder, pretty);
builder.Append(",");
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append("\n");
#endif
}
}
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Length -= 2;
else
#endif
builder.Length--;
}
#if (PRETTY)
#if(PRETTY)
if(pretty && list.Count > 0) {
builder.Append("\n");
for(int j = 0; j < depth - 1; j++)
@ -981,33 +987,33 @@ public class JSONObject {
case Type.ARRAY:
builder.Append("[");
if(list.Count > 0) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append("\n"); //for a bit more readability
#endif
for(int i = 0; i < list.Count; i++) {
if(list[i]) {
#if (PRETTY)
#if(PRETTY)
if(pretty)
for(int j = 0; j < depth; j++)
builder.Append("\t"); //for a bit more readability
#endif
list[i].Stringify(depth, builder, pretty);
builder.Append(",");
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Append("\n"); //for a bit more readability
#endif
}
}
#if (PRETTY)
#if(PRETTY)
if(pretty)
builder.Length -= 2;
else
#endif
builder.Length--;
}
#if (PRETTY)
#if(PRETTY)
if(pretty && list.Count > 0) {
builder.Append("\n");
for(int j = 0; j < depth - 1; j++)
@ -1028,12 +1034,12 @@ public class JSONObject {
}
//Profiler.EndSample();
}
#endregion
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#endregion
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
public static implicit operator WWWForm(JSONObject obj) {
WWWForm form = new WWWForm();
for(int i = 0; i < obj.list.Count; i++) {
string key = i + "";
string key = i.ToString(CultureInfo.InvariantCulture);
if(obj.type == Type.OBJECT)
key = obj.keys[i];
string val = obj.list[i].ToString();
@ -1075,10 +1081,10 @@ public class JSONObject {
JSONObject val = list[i];
switch(val.type) {
case Type.STRING: result.Add(keys[i], val.str); break;
case Type.NUMBER: result.Add(keys[i], val.n + ""); break;
case Type.BOOL: result.Add(keys[i], val.b + ""); break;
case Type.NUMBER: result.Add(keys[i], val.n.ToString(CultureInfo.InvariantCulture)); break;
case Type.BOOL: result.Add(keys[i], val.b.ToString(CultureInfo.InvariantCulture)); break;
default:
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.LogWarning
#else
Debug.WriteLine
@ -1089,7 +1095,7 @@ public class JSONObject {
}
return result;
}
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5
#if UNITY_2 || UNITY_3 || UNITY_4 || UNITY_5 || UNITY_5_3_OR_NEWER
Debug.Log
#else
Debug.WriteLine
@ -1120,6 +1126,64 @@ public class JSONObject {
}
}
#endif
IEnumerator IEnumerable.GetEnumerator()
{
return (IEnumerator)GetEnumerator();
}
public JSONObjectEnumer GetEnumerator()
{
return new JSONObjectEnumer(this);
}
}
public class JSONObjectEnumer : IEnumerator
{
public JSONObject _jobj;
// Enumerators are positioned before the first element
// until the first MoveNext() call.
int position = -1;
public JSONObjectEnumer(JSONObject jsonObject)
{
Debug.Assert(jsonObject.isContainer); //must be an array or object to itterate
_jobj = jsonObject;
}
public bool MoveNext()
{
position++;
return (position < _jobj.Count);
}
public void Reset()
{
position = -1;
}
object IEnumerator.Current
{
get
{
return Current;
}
}
public JSONObject Current
{
get
{
if (_jobj.IsArray)
{
return _jobj[position];
}
else
{
string key = _jobj.keys[position];
return _jobj[key];
}
}
}
}

19
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/LICENSE.md vendored

@ -0,0 +1,19 @@
Copyright (c) 2010-2019 Matt Schoen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

7
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/LICENSE.md.meta vendored

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d65b4117f5b5c3341947d0a81786e2cd
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

211
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/VectorTemplates.cs vendored

@ -0,0 +1,211 @@
using UnityEngine;
/*
Copyright (c) 2010-2019 Matt Schoen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
public static partial class JSONTemplates {
/*
* Vector2
*/
public static Vector2 ToVector2(JSONObject obj) {
float x = obj["x"] ? obj["x"].f : 0;
float y = obj["y"] ? obj["y"].f : 0;
return new Vector2(x, y);
}
public static JSONObject FromVector2(Vector2 v) {
JSONObject vdata = JSONObject.obj;
if(v.x != 0) vdata.AddField("x", v.x);
if(v.y != 0) vdata.AddField("y", v.y);
return vdata;
}
/*
* Vector3
*/
public static JSONObject FromVector3(Vector3 v) {
JSONObject vdata = JSONObject.obj;
if(v.x != 0) vdata.AddField("x", v.x);
if(v.y != 0) vdata.AddField("y", v.y);
if(v.z != 0) vdata.AddField("z", v.z);
return vdata;
}
public static Vector3 ToVector3(JSONObject obj) {
float x = obj["x"] ? obj["x"].f : 0;
float y = obj["y"] ? obj["y"].f : 0;
float z = obj["z"] ? obj["z"].f : 0;
return new Vector3(x, y, z);
}
/*
* Vector4
*/
public static JSONObject FromVector4(Vector4 v) {
JSONObject vdata = JSONObject.obj;
if(v.x != 0) vdata.AddField("x", v.x);
if(v.y != 0) vdata.AddField("y", v.y);
if(v.z != 0) vdata.AddField("z", v.z);
if(v.w != 0) vdata.AddField("w", v.w);
return vdata;
}
public static Vector4 ToVector4(JSONObject obj) {
float x = obj["x"] ? obj["x"].f : 0;
float y = obj["y"] ? obj["y"].f : 0;
float z = obj["z"] ? obj["z"].f : 0;
float w = obj["w"] ? obj["w"].f : 0;
return new Vector4(x, y, z, w);
}
/*
* Matrix4x4
*/
public static JSONObject FromMatrix4x4(Matrix4x4 m) {
JSONObject mdata = JSONObject.obj;
if(m.m00 != 0) mdata.AddField("m00", m.m00);
if(m.m01 != 0) mdata.AddField("m01", m.m01);
if(m.m02 != 0) mdata.AddField("m02", m.m02);
if(m.m03 != 0) mdata.AddField("m03", m.m03);
if(m.m10 != 0) mdata.AddField("m10", m.m10);
if(m.m11 != 0) mdata.AddField("m11", m.m11);
if(m.m12 != 0) mdata.AddField("m12", m.m12);
if(m.m13 != 0) mdata.AddField("m13", m.m13);
if(m.m20 != 0) mdata.AddField("m20", m.m20);
if(m.m21 != 0) mdata.AddField("m21", m.m21);
if(m.m22 != 0) mdata.AddField("m22", m.m22);
if(m.m23 != 0) mdata.AddField("m23", m.m23);
if(m.m30 != 0) mdata.AddField("m30", m.m30);
if(m.m31 != 0) mdata.AddField("m31", m.m31);
if(m.m32 != 0) mdata.AddField("m32", m.m32);
if(m.m33 != 0) mdata.AddField("m33", m.m33);
return mdata;
}
public static Matrix4x4 ToMatrix4x4(JSONObject obj) {
Matrix4x4 result = new Matrix4x4();
if(obj["m00"]) result.m00 = obj["m00"].f;
if(obj["m01"]) result.m01 = obj["m01"].f;
if(obj["m02"]) result.m02 = obj["m02"].f;
if(obj["m03"]) result.m03 = obj["m03"].f;
if(obj["m10"]) result.m10 = obj["m10"].f;
if(obj["m11"]) result.m11 = obj["m11"].f;
if(obj["m12"]) result.m12 = obj["m12"].f;
if(obj["m13"]) result.m13 = obj["m13"].f;
if(obj["m20"]) result.m20 = obj["m20"].f;
if(obj["m21"]) result.m21 = obj["m21"].f;
if(obj["m22"]) result.m22 = obj["m22"].f;
if(obj["m23"]) result.m23 = obj["m23"].f;
if(obj["m30"]) result.m30 = obj["m30"].f;
if(obj["m31"]) result.m31 = obj["m31"].f;
if(obj["m32"]) result.m32 = obj["m32"].f;
if(obj["m33"]) result.m33 = obj["m33"].f;
return result;
}
/*
* Quaternion
*/
public static JSONObject FromQuaternion(Quaternion q) {
JSONObject qdata = JSONObject.obj;
if(q.w != 0) qdata.AddField("w", q.w);
if(q.x != 0) qdata.AddField("x", q.x);
if(q.y != 0) qdata.AddField("y", q.y);
if(q.z != 0) qdata.AddField("z", q.z);
return qdata;
}
public static Quaternion ToQuaternion(JSONObject obj) {
float x = obj["x"] ? obj["x"].f : 0;
float y = obj["y"] ? obj["y"].f : 0;
float z = obj["z"] ? obj["z"].f : 0;
float w = obj["w"] ? obj["w"].f : 0;
return new Quaternion(x, y, z, w);
}
/*
* Color
*/
public static JSONObject FromColor(Color c) {
JSONObject cdata = JSONObject.obj;
if(c.r != 0) cdata.AddField("r", c.r);
if(c.g != 0) cdata.AddField("g", c.g);
if(c.b != 0) cdata.AddField("b", c.b);
if(c.a != 0) cdata.AddField("a", c.a);
return cdata;
}
public static Color ToColor(JSONObject obj) {
Color c = new Color();
for(int i = 0; i < obj.Count; i++) {
switch(obj.keys[i]) {
case "r": c.r = obj[i].f; break;
case "g": c.g = obj[i].f; break;
case "b": c.b = obj[i].f; break;
case "a": c.a = obj[i].f; break;
}
}
return c;
}
/*
* Layer Mask
*/
public static JSONObject FromLayerMask(LayerMask l) {
JSONObject result = JSONObject.obj;
result.AddField("value", l.value);
return result;
}
public static LayerMask ToLayerMask(JSONObject obj) {
LayerMask l = new LayerMask {value = (int)obj["value"].n};
return l;
}
public static JSONObject FromRect(Rect r) {
JSONObject result = JSONObject.obj;
if(r.x != 0) result.AddField("x", r.x);
if(r.y != 0) result.AddField("y", r.y);
if(r.height != 0) result.AddField("height", r.height);
if(r.width != 0) result.AddField("width", r.width);
return result;
}
public static Rect ToRect(JSONObject obj) {
Rect r = new Rect();
for(int i = 0; i < obj.Count; i++) {
switch(obj.keys[i]) {
case "x": r.x = obj[i].f; break;
case "y": r.y = obj[i].f; break;
case "height": r.height = obj[i].f; break;
case "width": r.width = obj[i].f; break;
}
}
return r;
}
public static JSONObject FromRectOffset(RectOffset r) {
JSONObject result = JSONObject.obj;
if(r.bottom != 0) result.AddField("bottom", r.bottom);
if(r.left != 0) result.AddField("left", r.left);
if(r.right != 0) result.AddField("right", r.right);
if(r.top != 0) result.AddField("top", r.top);
return result;
}
public static RectOffset ToRectOffset(JSONObject obj) {
RectOffset r = new RectOffset();
for(int i = 0; i < obj.Count; i++) {
switch(obj.keys[i]) {
case "bottom": r.bottom = (int)obj[i].n; break;
case "left": r.left = (int)obj[i].n; break;
case "right": r.right = (int)obj[i].n; break;
case "top": r.top = (int)obj[i].n; break;
}
}
return r;
}
}

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/VectorTemplates.cs.meta vendored

@ -0,0 +1,2 @@
fileFormatVersion: 1
guid: 886fb4d7a67d4ce4bb7f51bcc38e20c1

192
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.md vendored

@ -0,0 +1,192 @@
# Author
Matt Schoen <schoen@defectivestudios.com> of [Defective Studios](http://www.defectivestudios.com)
# Intro
I came across the need to send structured data to and from a server on one of my projects, and figured it would be worth my while to use JSON. When I looked into the issue, I tried a few of the C# implementations listed on http://json.org, but found them to be too complicated to work with and expand upon. So, I've written a very simple JSONObject class, which can be generically used to encode/decode data into a simple container. This page assumes that you know what JSON is, and how it works. It's rather simple, just go to json.org for a visual description of the encoding format.
As an aside, this class is pretty central to the AssetCloud content management system, from Defective Studios.
> **Update:** The code has been updated to version 1.4 to incorporate user-submitted patches and bug reports. This fixes issues dealing with whitespace in the format, as well as empty arrays and objects, and escaped quotes within strings.
# Usage
Users should not have to modify the JSONObject class themselves, and must follow the very simple proceedures outlined below:
Sample data (in JSON format):
```JSON
{
"TestObject": {
"SomeText": "Blah",
"SomeObject": {
"SomeNumber": 42,
"SomeBool": true,
"SomeNull": null
},
"SomeEmptyObject": { },
"SomeEmptyArray": [ ],
"EmbeddedObject": "{\"field\":\"Value with \\\"escaped quotes\\\"\"}"
}
}
```
## Features
* Decode JSON-formatted strings into a usable data structure
* Encode structured data into a JSON-formatted string
* Interoperable with `Dictionary` and `WWWForm`
* Optimized `parse`/`stringify` functions -- minimal (unavoidable) garbage creation
* Asynchronous `stringify` function for serializing lots of data without frame drops
* `MaxDepth` parsing will skip over nested data that you don't need
* Special (non-compliant) `Baked` object type can store stringified data within parsed objects
* Copy to new `JSONObject`
* Merge with another `JSONObject` (experimental)
* Random access (with `int` or `string`)
* `ToString()` returns JSON data with optional "pretty" flag to include newlines and tabs
* Switch between double and float for numeric storage depending on level of precision needed (and to ensure that numbers are parsed/stringified correctly)
* Supports `Infinity` and `NaN` values
* `JSONTemplates` static class provides serialization functions for common classes like `Vector3`, `Matrix4x4`
* Object pool implementation (experimental)
* Handy `JSONChecker` window to test parsing on sample data
It should be pretty obvious what this parser can and cannot do. If anyone reading this is a JSON buff (is there such a thing?) please feel free to expand and modify the parser to be more compliant. Currently I am using the .NET `System.Convert` namespace functions for parsing the data itself. It parses strings and numbers, which was all that I needed of it, but unless the formatting is supported by `System.Convert`, it may not incorporate all proper JSON strings. Also, having never written a JSON parser before, I don't doubt that I could improve the efficiency or correctness of the parser. It serves my purpose, and hopefully will help you with your project! Let me know if you make any improvements :)
Also, you JSON buffs (really, who would admit to being a JSON buff...) might also notice from my feature list that this thing isn't exactly to specifications. Here is where it differs:
* "a string" is considered valid JSON. There is an optional "strict" parameter to the parser which will bomb out on such input, in case that matters to you.
* The `Baked` mode is totally made up.
* The `MaxDepth` parsing is totally made up.
* `NaN` and `Infinity` aren't officially supported by JSON ([http://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript read more] about this issue... I lol'd @ the first comment on the first answer)
* I have no idea about edge cases in my parsing strategy. I have been using this code for about 3 years now and have only had to modify the parser because other people's use cases (still valid JSON) didn't parse correctly. In my experience, anything that this code generates is parsed just fine.
## Encoding
Encoding is something of a hard-coded process. This is because I have no idea what your data is! It would be great if this were some sort of interface for taking an entire class and encoding it's number/string fields, but it's not. I've come up with a few clever ways of using loops and/or recursive methods to cut down of the amount of code I have to write when I use this tool, but they're pretty project-specific.
Note: This section used to be WRONG! And now it's OLD! Will update later... this will all still work, but there are now a couple of ways to skin this cat.
```C#
// Note: your data can only be numbers and strings.
// This is not a solution for object serialization
// or anything like that.
JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
// number
j.AddField("field1", 0.5);
// string
j.AddField("field2", "sampletext");
// array
JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
j.AddField("field3", arr);
arr.Add(1);
arr.Add(2);
arr.Add(3);
string encodedString = j.print();
```
NEW! The constructor, Add, and AddField functions now support a nested delegate structure. This is useful if you need to create a nested JSONObject in a single line. For example:
```C#
DoRequest(URL, new JSONObject(delegate(JSONObject request) {
request.AddField("sort", delegate(JSONObject sort) {
sort.AddField("_timestamp", "desc");
});
request.AddField("query", new JSONObject(delegate(JSONObject query) {
query.AddField("match_all", JSONObject.obj);
}));
request.AddField("fields", delegate(JSONObject fields) {
fields.Add("_timestamp");
});
}).ToString());
```
## Decoding
Decoding is much simpler on the input end, and again, what you do with the `JSONObject` will vary on a per-project basis. One of the more complicated way to extract the data is with a recursive function, as drafted below. Calling the constructor with a properly formatted JSON string will return the root object (or array) containing all of its children, in one neat reference! The data is in a public `ArrayList` called `list`, with a matching key list (called `keys`!) if the root is an `Object`. If that's confusing, take a glance over the following code and the `print()` method in the `JSONObject` class. If there is an error in the JSON formatting (or if there's an error with my code!) the debug console will read "improper JSON formatting".
```C#
string encodedString = "{\"field1\": 0.5,\"field2\": \"sampletext\",\"field3\": [1,2,3]}";
JSONObject j = new JSONObject(encodedString);
accessData(j);
//access data (and print it)
void accessData(JSONObject obj){
switch(obj.type){
case JSONObject.Type.OBJECT:
for(int i = 0; i < obj.list.Count; i++){
string key = (string)obj.keys[i];
JSONObject j = (JSONObject)obj.list[i];
Debug.Log(key);
accessData(j);
}
break;
case JSONObject.Type.ARRAY:
foreach(JSONObject j in obj.list){
accessData(j);
}
break;
case JSONObject.Type.STRING:
Debug.Log(obj.str);
break;
case JSONObject.Type.NUMBER:
Debug.Log(obj.n);
break;
case JSONObject.Type.BOOL:
Debug.Log(obj.b);
break;
case JSONObject.Type.NULL:
Debug.Log("NULL");
break;
}
}
```
NEW! Decoding now also supports a delegate format which will automatically check if a field exists before processing the data, providing an optional parameter for an OnFieldNotFound response. For example:
```C#
new JSONObject(data);
list.GetField("hits", delegate(JSONObject hits) {
hits.GetField("hits", delegate(JSONObject hits2) {
foreach (JSONObject gameSession in hits2.list) {
Debug.Log(gameSession);
}
});
}, delegate(string name) { //"name" will be equal to the name of the missing field. In this case, "hits"
Debug.LogWarning("no game sessions");
});
```
## Not So New! `(O(n))` Random access!
I've added a string and int [] index to the class, so you can now retrieve data as such (from above):
```C#
JSONObject arr = obj["field3"];
Debug.log(arr[2].n); //Should ouptut "3"
```
## Change Log
### v1.4
Big update!
* Better GC performance. Enough of that garbage!
* Remaining culprits are internal garbage from `StringBuilder.Append`/`AppendFormat`, `String.Substring`, `List.Add`/`GrowIfNeeded`, `Single.ToString`
* Added asynchronous `Stringily` function for serializing large amounts of data at runtime without frame drops
* Added `Baked` type
* Added `MaxDepth` to parsing function
* Various cleanup refactors recommended by ReSharper
### v1.3.2
* Added support for `NaN`
* Added strict mode to fail on purpose for improper formatting. Right now this just means that if the parse string doesn't start with `[` or `{`, it will print a warning and return a `null` `JSONObject`.
* Changed `infinity` and `NaN` implementation to use `float` and `double` instead of `Mathf`
* Handles empty objects/arrays better
* Added a flag to print and `ToString` to turn on/off pretty print. The define on top is now an override to system-wide disable

7
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.md.meta vendored

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db6abf22260f8db43bc7e785f129ce0b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

188
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.txt vendored

@ -1,188 +0,0 @@
==Author==
[mailto:schoen@defectivestudios.com Matt Schoen] of [http://www.defectivestudios.com Defective Studios]
==Download==
[[Media:JSONObject.zip|Download JSONObject.zip]]
= Intro =
I came across the need to send structured data to and from a server on one of my projects, and figured it would be worth my while to use JSON. When I looked into the issue, I tried a few of the C# implementations listed on [http://json.org json.org], but found them to be too complicated to work with and expand upon. So, I've written a very simple JSONObject class, which can be generically used to encode/decode data into a simple container. This page assumes that you know what JSON is, and how it works. It's rather simple, just go to json.org for a visual description of the encoding format.
As an aside, this class is pretty central to the [[AssetCloud]] content management system, from Defective Studios.
Update: The code has been updated to version 1.4 to incorporate user-submitted patches and bug reports. This fixes issues dealing with whitespace in the format, as well as empty arrays and objects, and escaped quotes within strings.
= Usage =
Users should not have to modify the JSONObject class themselves, and must follow the very simple proceedures outlined below:
Sample data (in JSON format):
<nowiki>
{
"TestObject": {
"SomeText": "Blah",
"SomeObject": {
"SomeNumber": 42,
"SomeBool": true,
"SomeNull": null
},
"SomeEmptyObject": { },
"SomeEmptyArray": [ ],
"EmbeddedObject": "{\"field\":\"Value with \\\"escaped quotes\\\"\"}"
}
}</nowiki>
= Features =
*Decode JSON-formatted strings into a usable data structure
*Encode structured data into a JSON-formatted string
*Interoperable with Dictionary and WWWForm
*Optimized parse/stringify functions -- minimal (unavoidable) garbage creation
*Asynchronous stringify function for serializing lots of data without frame drops
*MaxDepth parsing will skip over nested data that you don't need
*Special (non-compliant) "Baked" object type can store stringified data within parsed objects
*Copy to new JSONObject
*Merge with another JSONObject (experimental)
*Random access (with [int] or [string])
*ToString() returns JSON data with optional "pretty" flag to include newlines and tabs
*Switch between double and float for numeric storage depending on level of precision needed (and to ensure that numbers are parsed/stringified correctly)
*Supports Infinity and NaN values
*JSONTemplates static class provides serialization functions for common classes like Vector3, Matrix4x4
*Object pool implementation (experimental)
*Handy JSONChecker window to test parsing on sample data
It should be pretty obvious what this parser can and cannot do. If anyone reading this is a JSON buff (is there such a thing?) please feel free to expand and modify the parser to be more compliant. Currently I am using the .NET System.Convert namespace functions for parsing the data itself. It parses strings and numbers, which was all that I needed of it, but unless the formatting is supported by System.Convert, it may not incorporate all proper JSON strings. Also, having never written a JSON parser before, I don't doubt that I could improve the efficiency or correctness of the parser. It serves my purpose, and hopefully will help you with your project! Let me know if you make any improvements :)
Also, you JSON buffs (really, who would admit to being a JSON buff...) might also notice from my feature list that this thing isn't exactly to specifications. Here is where it differs:
*"a string" is considered valid JSON. There is an optional "strict" parameter to the parser which will bomb out on such input, in case that matters to you.
*The "Baked" mode is totally made up.
*The "MaxDepth" parsing is totally made up.
*NaN and Infinity aren't officially supported by JSON ([http://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript read more] about this issue... I lol'd @ the first comment on the first answer)
*I have no idea about edge cases in my parsing strategy. I have been using this code for about 3 years now and have only had to modify the parser because other people's use cases (still valid JSON) didn't parse correctly. In my experience, anything that this code generates is parsed just fine.
== Encoding ==
Encoding is something of a hard-coded process. This is because I have no idea what your data is! It would be great if this were some sort of interface for taking an entire class and encoding it's number/string fields, but it's not. I've come up with a few clever ways of using loops and/or recursive methods to cut down of the amount of code I have to write when I use this tool, but they're pretty project-specific.
Note: This section used to be WRONG! And now it's OLD! Will update later... this will all still work, but there are now a couple of ways to skin this cat.
<syntaxhighlight lang="csharp">
//Note: your data can only be numbers and strings. This is not a solution for object serialization or anything like that.
JSONObject j = new JSONObject(JSONObject.Type.OBJECT);
//number
j.AddField("field1", 0.5);
//string
j.AddField("field2", "sampletext");
//array
JSONObject arr = new JSONObject(JSONObject.Type.ARRAY);
j.AddField("field3", arr);
arr.Add(1);
arr.Add(2);
arr.Add(3);
string encodedString = j.print();
</syntaxhighlight>
NEW! The constructor, Add, and AddField functions now support a nested delegate structure. This is useful if you need to create a nested JSONObject in a single line. For example:
<syntaxhighlight lang="csharp">
DoRequest(URL, new JSONObject(delegate(JSONObject request) {
request.AddField("sort", delegate(JSONObject sort) {
sort.AddField("_timestamp", "desc");
});
request.AddField("query", new JSONObject(delegate(JSONObject query) {
query.AddField("match_all", JSONObject.obj);
}));
request.AddField("fields", delegate(JSONObject fields) {
fields.Add("_timestamp");
});
}).ToString());
</syntaxhighlight>
== Decoding ==
Decoding is much simpler on the input end, and again, what you do with the JSONObject will vary on a per-project basis. One of the more complicated way to extract the data is with a recursive function, as drafted below. Calling the constructor with a properly formatted JSON string will return the root object (or array) containing all of its children, in one neat reference! The data is in a public ArrayList called list, with a matching key list (called keys!) if the root is an Object. If that's confusing, take a glance over the following code and the print() method in the JSONOBject class. If there is an error in the JSON formatting (or if there's an error with my code!) the debug console will read "improper JSON formatting".
<syntaxhighlight lang="csharp">
string encodedString = "{\"field1\": 0.5,\"field2\": \"sampletext\",\"field3\": [1,2,3]}";
JSONObject j = new JSONObject(encodedString);
accessData(j);
//access data (and print it)
void accessData(JSONObject obj){
switch(obj.type){
case JSONObject.Type.OBJECT:
for(int i = 0; i < obj.list.Count; i++){
string key = (string)obj.keys[i];
JSONObject j = (JSONObject)obj.list[i];
Debug.Log(key);
accessData(j);
}
break;
case JSONObject.Type.ARRAY:
foreach(JSONObject j in obj.list){
accessData(j);
}
break;
case JSONObject.Type.STRING:
Debug.Log(obj.str);
break;
case JSONObject.Type.NUMBER:
Debug.Log(obj.n);
break;
case JSONObject.Type.BOOL:
Debug.Log(obj.b);
break;
case JSONObject.Type.NULL:
Debug.Log("NULL");
break;
}
}
</syntaxhighlight>
NEW! Decoding now also supports a delegate format which will automatically check if a field exists before processing the data, providing an optional parameter for an OnFieldNotFound response. For example:
<syntaxhighlight lang="csharp">
new JSONObject(data);
list.GetField("hits", delegate(JSONObject hits) {
hits.GetField("hits", delegate(JSONObject hits2) {
foreach (JSONObject gameSession in hits2.list) {
Debug.Log(gameSession);
}
});
}, delegate(string name) { //"name" will be equal to the name of the missing field. In this case, "hits"
Debug.LogWarning("no game sessions");
});
</syntaxhighlight>
===Not So New! (O(n)) Random access!===
I've added a string and int [] index to the class, so you can now retrieve data as such (from above):
<syntaxhighlight lang="csharp">
JSONObject arr = obj["field3"];
Debug.log(arr[2].n); //Should ouptut "3"
</syntaxhighlight>
----
---Code omitted from readme---
=Change Log=
==v1.4==
Big update!
*Better GC performance. Enough of that garbage!
**Remaining culprits are internal garbage from StringBuilder.Append/AppendFormat, String.Substring, List.Add/GrowIfNeeded, Single.ToString
*Added asynchronous Stringify function for serializing large amounts of data at runtime without frame drops
*Added Baked type
*Added MaxDepth to parsing function
*Various cleanup refactors recommended by ReSharper
==v1.3.2==
*Added support for NaN
*Added strict mode to fail on purpose for improper formatting. Right now this just means that if the parse string doesn't start with [ or {, it will print a warning and return a null JO.
*Changed infinity and NaN implementation to use float and double instead of Mathf
*Handles empty objects/arrays better
*Added a flag to print and ToString to turn on/off pretty print. The define on top is now an override to system-wide disable
==Earlier Versions==
I'll fill these in later...
[[Category:C Sharp]]
[[Category:Scripts]]
[[Category:Utility]]
[[Category:JSON]]

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/JSON/readme.txt.meta vendored

@ -1,2 +0,0 @@
fileFormatVersion: 1
guid: 80b692916bec1664098283aa4425e4d8
Loading…
Cancel
Save