using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using System.Text;
using GFW;
using Newtonsoft.Json;
//public class UserConfigData
//{
// public Dictionary<string, object> configDataDic = new Dictionary<string, object>();
//}
public class UserPersonData
{
public string curUserID;
public Dictionary<string, object> curUserDataDic = new Dictionary<string, object>();
}
public class GSetting {
static string curUserID = "data";
static string _saveDataPath = Application.dataPath + "/../WriteablePath/json/_current_userdata.json";
// ----SetConfig
public static void SetValue(string dataKey, object dataValue)
{
if (string.IsNullOrEmpty(dataKey))
{
Debug.Log(" is null !");
return;
}
if (RefreshData(dataKey,dataValue))
{
return;
}
UserPersonData _newUserConfigData = new UserPersonData();
_newUserConfigData.curUserDataDic[dataKey] = dataValue;
string _saveData = JsonConvert.SerializeObject(_newUserConfigData);
if (!string.IsNullOrEmpty(_saveData))
{
_saveData = _saveData + "\r\n";
数据持久化(保存Json文件)---Newtonsoft Json
最新推荐文章于 2024-09-06 00:12:14 发布
这篇博客详细介绍了如何利用Newtonsoft Json库将数据持久化到Json文件中,为开发者提供了一种实用的数据存储解决方案。
摘要由CSDN通过智能技术生成