c# - Desearlizing an array of json objects into an object -


I am trying to deserialize the JSON object from battle.net apis, I can not locate the format of the class I am weighing the Jason object

The "race" array is always empty during the runtime.

I am using the same request to collect data for the same service, so the rest of the problem is not requested.

I am using C # with the RestSharp library

Here I am deserializing Jason:

  {"races": [ {"Id": 5, "mask": 16, "side": "gang": "gang", "id": "gang", "name": "gang", "name": "gang" , "" "," "", "", "" "," "," "," "," "," "," "", "" "," "", "" "," "", "" "", "Name": "gang", "name": "orc"}, {"id": 7, "mask": 64, side ":" combine "," name ":" gnom "}, {" id ": 9, "mask": 256, "side": "gang", "name": "ghost"}, {"id": "favor": 1, "side": "coalition", "name" "", {"Id": 8, "mask": 128, "side": "gang", "name": "" "" "," "", "mask": " X ":" side ":" side ":" neutral "," name ":" panderer "}, {" id ": 11," mask ": 1024, side": "coalition", "name": " "", "Id:", "mask": 20 9 7152, "side": "alliance", "name": "wargan"}, {"id": 10, "mask": 512, "favor ":" Elf ")," name ":" nick "," name ":" idle "," id ": {" id ": 4," mask ": 8," side ":" coalition "," name "}, {" id "," Side ":" alliance "," name ":" dwarf "}, {" id ": 25," mask ": 16777216," side ":" coalition "," name ":" Pandaren "}, {" id ": 26," mask ": 33554432," side ":" gang "," name ":" panderer "}}}   

Here in the class I Trying to deserialize:

  using the system; Using System.Collections.Generic; Namespace RESTTests {public class race {Public Ent ID (Received); Set; } Public Int mask {get; Set; } Public string side {get; Set; } Public string name {get; Set; }} Public Squared Race {Public Race [] Run {Received; Set; }}}   

Edit: More code by request

  Public Zero GetRaceData () {var Client = CreateClient (); Var request = CreateRequest ("wow / data / character / class"); IRestResponse & LT; RaceData & gt; ResponseDe = client.Execute & lt; Racing & gt; (request); Racedata race = feedback.data; // The race point object is zero at this point "race" and the race in the reaction. Data objects are also empty) Private RestRequest CreateRequest (string segement) {var request = New RestRequest (segement, Method.GET); Request.AddParameter ("locale", _locale); Request.AddParameter ("APKI", _apiKey); Return request; } Private Rest Client CreateClient () {var Client = New Rest Client ("https://us.api.battle.net/"); Return customer; }  "post-text" itemprop = "text"> 

You can try using the sample for:

  code> string json = "here's your Load Jason as a String "; Running Race = JsonConvert.DeserializeObject & lt; Race & gt; (json);   

I think RestSharp lib is already referred to as a dependency Json.NET, therefore, you can use it from there.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -