using ICSharpCode.SharpZipLib.Checksum;
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
/// <summary>
/// Json处理
/// </summary>
public class JSONTool
{
public static T Parse<T>(string jsonStr)
where T : class
{
try
{
T t = JsonUtility.FromJson<T>(jsonStr);
return t;
}
catch (Exception ex)
{
D.LogError("Json Untility Err Msg :" + ex.Message);
}
return null;
}
public static string ToString<T>(T obj)
where T : class
{
try
{
string jsonStr = JsonUtility.ToJson(obj);
//Debuger.Log("===> Json String is [" + jsonStr + "]");
return jsonStr;
}
catch (Exception ex)
{
D.LogError("Json Untility Err Msg :" + ex.Message);
}
return "";
}
}
UNITY中使用JSONUTILITY解析JSON
Unity5.3 JsonUtility的使用
|