1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class JsonManager : MonoBehaviour
- {
- public const string TAG = "JsonManager";
- private static JsonManager m_Instance;
-
- public static JsonManager Instance
- {
- get
- {
- if (null == JsonManager.m_Instance)
- {
- GameObject gameObject = GameObject.Find("JsonManager");
- if (null == gameObject)
- {
- gameObject = new GameObject("JsonManager");
- gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
- DontDestroyOnLoad(gameObject);
- }
- m_Instance = gameObject.AddComponent<JsonManager>();
- }
- return m_Instance;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public bool AnalysisJson(string jsonData)
- {
- if (jsonData == "" || jsonData == "Message")
- {
- Debug.LogError("未接受到json 数据");
- return false;
- }
- try
- {
-
- QuestionInfor infor = JsonMapper.ToObject<QuestionInfor>(jsonData);
- return true;
- }
- catch (Exception)
- {
- Debug.LogError("Json 传入格式不正确 无法解析");
- return false;
- }
- }
- }
|