public JSONNode GetDataSet(string strKey, bool bMake = false) { if (m_RootNode == null) { return(null); } foreach (JSONNode nodeData in m_RootNode.Children) { JSONObject data = nodeData[strKey] as JSONObject; if (data != null) { return(data); } else if (bMake) { JSONObject classData = JSONDataStruct.MakeDictionary(); nodeData[strKey] = classData; return(classData); } } return(null); }
public IEnumerator CheckSettingData(string strCDNurl) { string fileurl = strCDNurl + "TCPsetting.json"; UnityWebRequest TCPsettingjsonWWW = UnityWebRequest.Get(fileurl); yield return(TCPsettingjsonWWW.SendWebRequest()); if (TCPsettingjsonWWW.error != null) { Debug.LogError("TCPsettingjsonWWW error : " + TCPsettingjsonWWW.error); yield break; } string strTcpSettingText = TCPsettingjsonWWW.downloadHandler.text; if (string.IsNullOrEmpty(strTcpSettingText) == false) { var dicsetting = JSON.Parse(strTcpSettingText) as JSONObject; if (dicsetting != null) { int nTCPmode = 0; nTCPmode = JSONDataStruct.GetDataInt(dicsetting, "TCPMODE"); } } }
public void AddData(string strKey, string strData) { if (m_RootNode == null) { m_RootNode = JSONDataStruct.MakeDictionary(); } m_RootNode.Add(strKey, strData); }
public void MakeMainNode(string strMainKey) { if (m_RootNode == null) { m_RootNode = JSONDataStruct.MakeDictionary(); } JSONObject classNode = JSONDataStruct.MakeDictionary(); m_RootNode.Add(strMainKey, classNode); }
public static JSONArray ArrayToJSON(string[] arrData) { JSONArray arr = JSONDataStruct.MakeArray(); if (arrData == null) { return(arr); } for (int i = 0; i < arrData.Length; ++i) { arr.Add(arrData[i]); } return(arr); }
public static JSONArray ListToJSON(List <string> listData) { JSONArray arr = JSONDataStruct.MakeArray(); if (listData == null) { return(arr); } for (int i = 0; i < listData.Count; ++i) { arr.Add(listData[i]); } return(arr); }
public JSONNode AddDataSet(string strKey) { if (m_RootNode == null) { return(null); } JSONNode newData = JSONDataStruct.MakeDictionary(); foreach (JSONNode nodeData in m_RootNode.Children) { nodeData.Add(strKey, newData); break; } return(GetDataSet(strKey)); }
public JSONNode AddDataSet(int nIndex) { if (m_RootNode == null) { return(null); } JSONNode newData = JSONDataStruct.MakeDictionary(); foreach (JSONNode nodeData in m_RootNode.Children) { nodeData.Add(nIndex.ToString(), newData); break; } return(GetDataSet(nIndex)); }
public static JSONObject DicToJSON(Dictionary <int, int> dicData) { JSONObject dic = JSONDataStruct.MakeDictionary(); if (dicData == null) { return(dic); } var enumerator = dicData.GetEnumerator(); while (enumerator.MoveNext()) { dic.Add(enumerator.Current.Key.ToString(), enumerator.Current.Value); } return(dic); }
public static bool UpdateTextAssetFromDirectory(DirectoryInfo directoryInfo, string assetName, out JSONNode outputNode) { outputNode = null; #if UNITY_EDITOR || UNITY_STANDALONE // 에디터 또는 서버 빌드일 경우 if (null == directoryInfo || false == directoryInfo.Exists || true == string.IsNullOrEmpty(assetName)) { return(false); } string fileFullPath = directoryInfo.FullName + "/" + assetName + ".json"; try { FileInfo fileInfo = new FileInfo(fileFullPath); if (false == fileInfo.Exists || 0L == fileInfo.Length) { return(false); } UpdatedTextAssetData updatedTextAssetData = null; if (false == s_dicUpdatedTextAssetData.TryGetValue(fileFullPath, out updatedTextAssetData) || null == updatedTextAssetData) { updatedTextAssetData = new UpdatedTextAssetData(); s_dicUpdatedTextAssetData[fileFullPath] = updatedTextAssetData; } if (null == updatedTextAssetData) { return(false); } if (fileInfo.LastWriteTime.Ticks > updatedTextAssetData.LastUpdateTicks) { using (StreamReader streamReader = fileInfo.OpenText()) { string readData = streamReader.ReadToEnd(); updatedTextAssetData.JsonNodeData = JSON.Parse(readData); updatedTextAssetData.LastUpdateTicks = fileInfo.LastWriteTime.Ticks; } outputNode = updatedTextAssetData.JsonNodeData; return(true); } else { outputNode = updatedTextAssetData.JsonNodeData; return(false); } } catch (Exception ex) { Debug.LogError(ex.Message); return(false); } #else // 클라 빌드에서 Virtual 모드일 경우 JSONDataStruct dataStruct = new JSONDataStruct(); UpdatedTextAssetData updatedTextAssetData = null; if (true == s_dicUpdatedTextAssetData.TryGetValue(assetName, out updatedTextAssetData)) { outputNode = updatedTextAssetData.JsonNodeData; return(true); } if (false == dataStruct.LoadJSONFile(assetName)) { return(false); } updatedTextAssetData = new UpdatedTextAssetData(); outputNode = updatedTextAssetData.JsonNodeData = dataStruct.RootNode; s_dicUpdatedTextAssetData[assetName] = updatedTextAssetData; return(true); #endif }