I am doing a WebApi Method in Visual Studio 2013 and I want to Deserialize a Class Type. My Class is like this
[JsonObject]
class JOTA
{
[JsonProperty("ProductId")]
public int ProductId { get; set; }
[JsonProperty("Name")]
public string Name { get; set; }
}
My call is like this.
public void ReturnListProd(JOTA PP)
{
JOTA product = Newtonsoft.Json.JsonConvert.DeserializeObject<JOTA>(PP);
}
I have a compile error
'Network.Json.Json.Converter[] has some invalid argument'
But, if a define an ArrayList
public void ReturnListProd(ArrayList PP)
{
JOTA product = Newtonsoft.Json.JsonConvert.DeserializeObject<JOTA>(PP[0].ToString());
}
I have no error. But in this case, it does not help on what I need.
What I am missing? Thanks
JOTAobject (not a serialized version) and deserialize it to a JOTA object again? In that case, your method body would simply beJOTA product = PP;Also, why do your methods returnvoid, you are just throwing away the result? The second example isn't a compile time error, but I'm betting it would be a run-time one.DeserializeObjectmethod takes astringas a parameter but you are giving it aJOTAobject. The error tells you exactly what the problem is.