Reputation: 1664
I have a string that contains JSON data and I want to convert it to string or string array in C#.
I'm getting exception of type JSONReaderException
Additional text encountered after finished reading JSON content: :. Path '', line 1, position 7
What is the meaning of it?
Here is my code:
string requestType = Request.QueryString[0].ToString();
JObject json = JObject.Parse(requestType);
JavaScriptSerializer j = new JavaScriptSerializer();
string b = JsonConvert.DeserializeObject<string>(requestType.Substring(1,requestType.Length-2));
The data is sent to the server from AJAX request. I'm attaching the request:
$.ajax({
url: "AJAXRequests.aspx",
type: "get",
data: JSON.stringify({ "first": "getevent","second":"data" }),
dataType:'json',
success: function (response){
},
error: function (xhr) {
alert("Problem in sending data to the server.\n Please check your internet connection and try again");
}
});
Upvotes: 1
Views: 637
Reputation: 35696
A JSONReaderException
with the message "Additional text encountered after finished reading JSON content: :. Path '', line 1, position 7"
means,
the string you are parsing has some JSON at the start followed by something else that is not JSON.
In this case, the part that is not JSON starts a position 7 on line 1.
Upvotes: 1