Unexpected character encountered while parsing value

 

Introduction

Thank you for landing here to grab expected solution.

I'm sure JSON caused you a bit shake.

Yes- I did the same googling a lot and this could be your right solution.

This article shares step by step solution what might have caused error.  As the error message stated 'encountered while parsing value'  explains you have value could be string or an object that not fit into JSON serialization.

Now, let's get into an action. 

Below image describes an exception thrown while parsing value.

Unexpected character encountered while parsing

 

 Alright, from the above exceptions there could be lot of ways you encountered. To narrow down exactly what line of code did this error to me.

Now, take a look at code below. 

JSON Convert


From number #1 

Http response returns the jsonResult as string

From number #2

Json Convert is trying to De-serialize as object from json result. 


How to Solve the problem?

The solution as marked #1 is expected to return json result but actually returned as "html/text" format. 

Sometimes you may not actually passing json to DeserializeObject  

Having said that before, always make sure before Deserializeobject; Json result must be passed to JsonConvert. 

This is how the expected result looks like


Json Convert - Solved

  
  

Summary

Thank you for your time, from this article take away to read the problem twice will help to shorten our time to find solution. And explained what json format value must be passed before Json convert deserializing object, and sometimes your returned value might have "html/text" instead of "json/text".