public static CFXEnvelope FromJson(string jsonData) { CFXEnvelope env = CFXJsonSerializer.DeserializeObject <CFXEnvelope>(jsonData); Type tp = Type.GetType(env.MessageName); env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp); return(env); }
public static List <CFXEnvelope> FromJsonList(string jsonData) { List <CFXEnvelope> list = CFXJsonSerializer.DeserializeObject <List <CFXEnvelope> >(jsonData); foreach (CFXEnvelope env in list) { Type tp = Type.GetType(env.MessageName); env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp); } return(list); }
public static CFXEnvelope FromJson(string jsonData) { CFXEnvelope env = CFXJsonSerializer.DeserializeObject <CFXEnvelope>(jsonData); // For backwards compatibility. Older versions of the SDK did not properly decorate the $type of the MessageBody property, // so the message portion had to be deserialized individually, which was inefficient. if (!(env.MessageBody is CFXMessage)) { Type tp = Type.GetType(env.MessageName); env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp); } return(env); }
public static List <CFXEnvelope> FromJsonList(string jsonData) { List <CFXEnvelope> list = CFXJsonSerializer.DeserializeObject <List <CFXEnvelope> >(jsonData); foreach (CFXEnvelope env in list) { // For backwards compatibility. Older versions of the SDK did not properly decorate the $type of the MessageBody property, // so the message portion had to be deserialized individually, which was inefficient. if (!(env.MessageBody is CFXMessage) && !string.IsNullOrWhiteSpace(env.messageName)) { Type tp = Type.GetType(env.messageName); env.MessageBody = CFXJsonSerializer.DeserializeObject(env.MessageBody.ToString(), tp); } } return(list); }
public static T FromBytes <T>(byte [] data) where T : CFXMessage { return(CFXJsonSerializer.DeserializeObject <T>(Encoding.UTF8.GetString(data))); }
public static T FromJson <T>(string jsonData) where T : CFXMessage { return(CFXJsonSerializer.DeserializeObject <T>(jsonData)); }