Mycroft.Messages.Msg.MsgQuery.Deserialize C# (CSharp) Méthode

Deserialize() public static méthode

public static Deserialize ( string json ) : DataPacket
json string
Résultat DataPacket
        public static new DataPacket Deserialize(string json)
        {
            try
            {
                MsgQuery ret = new MsgQuery();
                dynamic obj = Json.Decode(json);
                ret.Id = obj["id"];
                if (ret.Id == null)
                    throw new ParseException(json, "No id found");
                ret.Capability = obj["capability"];
                if (ret.Capability == null)
                    throw new ParseException(json, "No capability found");
                ret.Action = obj["action"];
                if (ret.Action == null)
                    throw new ParseException(json, "No action found");
                ret.Data = ParseDataThing(obj["data"]);
                ret.InstanceId = new List<string>();
                DynamicJsonArray instanceIds = obj["instanceId"];
                if (instanceIds != null)
                {
                    foreach (object elem in instanceIds)
                    {
                        ret.InstanceId.Add(elem.ToString());
                    }
                }
                ret.Priority = obj["priority"];
                return ret;
            }
            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException)
            {
                throw new ParseException(json, "General binding exception. Is something invalid?");
            }
            catch (ArgumentException)
            {
                throw new ParseException(json, "Invalid JSON");
            }
        }