29 lines
704 B
C#
29 lines
704 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
public class JSONInterpreter
|
|
{
|
|
|
|
public static MessageObject Json2MessageObject(string json)
|
|
{
|
|
return JsonConvert.DeserializeObject<MessageObject>(json);
|
|
}
|
|
|
|
public static string MessageObject2Json(MessageObject mo)
|
|
{
|
|
return JsonConvert.SerializeObject(mo);
|
|
}
|
|
|
|
public static byte[] MessageObject2RawJson(MessageObject mo)
|
|
{
|
|
return System.Text.Encoding.UTF8.GetBytes(MessageObject2Json(mo));
|
|
}
|
|
|
|
public static MessageObject RawJson2MessageObject(byte[] raw_json)
|
|
{
|
|
return Json2MessageObject(System.Text.Encoding.UTF8.GetString(raw_json));
|
|
}
|
|
} |