2024-10-22 16:10:12 +08:00
|
|
|
using System;
|
2024-08-17 14:27:18 +08:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
2024-10-17 01:59:25 +08:00
|
|
|
namespace JNGame.Runtime.Util {
|
2024-08-17 14:27:18 +08:00
|
|
|
public static class JsonUtil {
|
|
|
|
public static string ToJson(object obj){
|
|
|
|
return JsonConvert.SerializeObject(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T ToObject<T>(string txt){
|
|
|
|
return JsonConvert.DeserializeObject<T>(txt);
|
|
|
|
}
|
2024-10-22 16:10:12 +08:00
|
|
|
public static object ToObject(string txt,Type type){
|
|
|
|
return JsonConvert.DeserializeObject(txt,type);
|
|
|
|
}
|
2024-08-17 14:27:18 +08:00
|
|
|
}
|
|
|
|
}
|