using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
|
|
namespace Hydro.CommonBase
|
{
|
public class json
|
{
|
public static dynamic loads(string s)
|
{
|
try
|
{
|
return JsonConvert.DeserializeObject<JObject>(s).Todict() as dict;
|
|
}
|
catch
|
{
|
return JsonConvert.DeserializeObject<List<string>>(s);
|
}
|
}
|
|
public static string dumps(object s)
|
{
|
try
|
{
|
return JsonConvert.SerializeObject(s);
|
}
|
catch
|
{
|
return JsonConvert.SerializeObject(s);
|
}
|
}
|
}
|
}
|