How to Deserialize a very Simple RestSharp JSON Object? -
Sorry that's definitely a dumb question, but I'm just using JSON with C #.
I have this class:
public class DBCount {public string calculation {get; Set; }}
Let me create an example:
public DBCN dbcount;
My web service is returning to:
[{"Census": "234"}]
This code throws an invalid artist when He tries to deserialize the response:
var client = new rest client ("http: //www.../") var request = new resuquest ("demo / jsodbcount.fp ", Method. GET); Request.RequestFormat = DataFormat.Json; Var response = client.Execute (request); RestSharp.Deserializers.JsonDeserializer deserialCount = New JsonDeserializer (); DbCount = deserialCount.Deserialize & lt; DBCount> (reaction);
"Destination type can not be entered from source type"
If someone can tell me a simple, simple example, I should be very grateful I have a basic The code is searched everywhere for sample.
Thank you
You already thought this but the problem is []
. [{"" count: "234"}
is an array of size <1 in which the field is an object with calculation
.
If you want your server to return an object that will deserialize for DBCount
and then {"Count": "234"}
Without []
.
If you want your code to be deserialize correctly, you need to indicate that it deserialize the archive; [["count": "234"}]
Like:
deserialCount.Deserialize & lt; List & lt; DBCount> & Gt; (reaction);
Comments
Post a Comment