0

I am deserializing json data from an online api. The json can be deserialized using the following:

dynamic json = JsonConvert.DeserializeObject(jsonData);

Where jsonData is just a string containing the downloaded content. When I try and perform the following action however:

DataSet master = JsonConvert.DeserializeObject<DataSet>(jsonData);

I get the following error:

Additional text found in JSON string after finishing deserializing object.

I have verified the validity of the json using multiple online resources. What could be the problem?

The data I am trying to deserialize can be found here: api.hearthstonejson.com/v1/latest/enUS/cards.json

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
user3081814
  • 141
  • 1
  • 1
  • 11
  • Can you post the contents of the `jsonData` variable? It's possible that the JSON data is not in a format suitable for serializing to a data-set (e.g. it has nested elements) – RB. Feb 24 '16 at 09:21
  • Data can be found here: https://api.hearthstonejson.com/v1/latest/enUS/cards.json – user3081814 Feb 24 '16 at 09:25
  • It's just too long to post in a comment – user3081814 Feb 24 '16 at 09:26
  • You can't deserialize to a DataSet, you need to deserialize to a DataTable. A DataSet is a container for DataTables, it doesn't contain any data itself – Panagiotis Kanavos Feb 24 '16 at 09:30
  • JSON.Net provides facilities for deserialing to a DataSet and has worked previously. It can deserialize the data into a "dynamc" FastExpando type collection but will not deserialize to a DataSet as shown in the examples. – user3081814 Feb 24 '16 at 09:30
  • @user3081814 DataTable, not DataSet. If you think the data causes issues, post a sample that can produce the error *in the question*. – Panagiotis Kanavos Feb 24 '16 at 09:31
  • @PanagiotisKanavos it is supposed to work to DataSet, see their website for examples. – user3081814 Feb 24 '16 at 09:55

0 Answers0