Reputation: 7
I am trying to sent username as raj"gogetter"mclean using JSON but getting below error:
{"$errorDump":"org.codehaus.jackson.JsonParseException:Unexpected character ('g' (code 103)):was expecting comma to separate OBJECT entries\n at [Source: com.softwareag.is.enterprisegateway.net.HttpInputStream@3b2827cd;
I am using string format like below:
Utility.GetGlobalSSOWebMethod("POST", uri, ref statusCode, @"{""username"": """ + userName + @""",""password"":""" + password + @""",""country"":""" + this.CountryCode + @""",""redirect"":""" + redirectApplicationUrl + @"""}");
This is the json object which is causing an error:
I tried looking to few questions posted here but not the exact issue happened.Also please suggest how to use Json serializer instead of string concatenations.
Upvotes: 0
Views: 842
Reputation: 31
You might need to escape quotes (\" instead of ") if you are embedding a string in a JSON string. An example could be that you are trying to embed some HTML into a JSON string, and this HTML contains quotes and all these fabulous things which break the serialization.
Upvotes: 1