H, I'm trying to use ServiceStack.Text to parse JSON (it seems to work better than JSON.Net in the various tests I've seen). But I do not get the expected results. The class I'm trying to deserialize is as follows:
[DataContract]
public class RpcRequest<T>
{
[JsonProperty("id")]
[DataMember(Name="id")]
public String Id;
[JsonProperty("method")]
[DataMember(Name="method")]
public String Method;
[JsonProperty("params")]
[DataMember(Name="params")]
public T Params;
[JsonIgnore]
[IgnoreDataMember]
public Policy Policy;
}
And I call a parser like this
public static class Json
{
public static T Deserialize<T>(string serialized)
{
return TypeSerializer.DeserializeFromString<T>(serialized);
}
}
...
RpcRequest<Params> myRequeset = Json.Deserialize(packet);
However, I am returning an instance from this call that does not have any of the set values. those. Id, Methodand Params- all values are equal to zero. Am I using this API correctly?
source
share