public static old.JSONObject GetJSONObject(this old.JSONObject json, string key) { int id = json.keys.IndexOf(key); if (id < 0) { return(null); } return(json.list[id]); }
public noteinfo(old.JSONObject jsonNote) { /* * "_time":4.300000190734863, * "_lineIndex":0, * "_lineLayer":1, * "_type":0, * "_cutDirection":4 */ time = jsonNote.GetJSONObject("_time").f; type = (int)jsonNote.GetJSONObject("_type").i; }
// Start is called before the first frame update void Start() { old.JSONObject obj = new old.JSONObject(taNoteJson.text); int notesID = obj.keys.FindIndex(i => i == "_notes"); old.JSONObject notes = obj.list[notesID]; foreach (var note in notes.list) { int timeID = note.keys.FindIndex(i => i == "_time"); float time = note.list[timeID].f; listTimeNote.Add(new KeyValuePair <float, old.JSONObject>(time, note)); } listTimeNote.Sort((x, y) => x.Key.CompareTo(y.Key)); asSong.Play(); }
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 = old.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 old.JSONObject(text); Debug.Log(j.ToString(true)); } } if (j) { //Debug.Log(System.GC.GetTotalMemory(false) + ""); if (j.type == old.JSONObject.Type.NULL) { GUILayout.Label("JSON fail:\n" + j.ToString(true)); } else { GUILayout.Label("JSON success:\n" + j.ToString(true)); } } }