-1

Code im trying:

        public static void Values() {
            using (WebClient wb = new WebClient()) {
                wb.Headers["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36";
                Dictionary<string, string> dictObj = JsonConvert.DeserializeObject<Dictionary<string, string>>(wb.DownloadString("https://www.rolimons.com/itemapi/itemdetails"));
                Console.WriteLine(dictObj.Keys);
            }
         }

Error its outputting:

Unexpected character encountered while parsing value: {. Path 'items', line 1, position 43

Im trying to output all of the json names.

  • Start by saving the JSON string in a variable and ensuring it matches a `Dictionary`. Probably not, according to the error. – CodeCaster Aug 12 '20 at 18:24
  • try wb.DownloadString("https://www.rolimons.com/itemapi/itemdetails") with the actual string and see if the error persist. – Rajkumar Bansal Aug 12 '20 at 18:25

2 Answers2

0

item's field value is not a string but an array. Check the image below.enter image description here

Rajkumar Bansal
  • 323
  • 2
  • 10
0

Your output has 3 fields and 3rd one is a List which again has a list as a value. So to Deserialize it, you need one class with your fields. Then use JObject and JToken to get actual values. Below link has similar answer.
https://stackoverflow.com/a/2246724/5829426

Ajay
  • 209
  • 2
  • 13