-1
Response.ContentType = "text/plain";

System.IO.Stream inptStrm = Request.InputStream;

byte[] bytes = new byte[inptStrm.Length];

int i = inptStrm.Read(bytes, 0, Convert.ToInt32(inptStrm.Length));

string Input = Encoding.UTF8.GetString(bytes);
JsonTextParser parsor = new JsonTextParser();

JsonObject jsonObj = parsor.Parse(Input);

My input string is :::::

{
  "function":"addwhy",

  "lastname":"\"", // this line


}

My agent did also try to convert it to UTF8 format but,my code generated error when it goes for parsor.

Parin Parikh
  • 44
  • 1
  • 6

3 Answers3

1

It should just be a backslash, as in...

"shopname":"\"\""
"lastname": "\"\"",

If you add this JSON...

{
    "function": "addwhy",
    "firstname": "firstname",
    "lastname": "\"\"",
    "dob": "8/8/2001",
    "dop": "testplace",
    "street": "teststreet",
    "nr": "testnr",
    "postcode": "123456",
    "place": "testplace",
    "telephone": "telephone",
    "incidentid": "1",
    "Aangehoudendoor": "testAangehoudendoor",
    "Waar": "testWaar",
    "DayTime": "Monday,
    6: 48PM",
    "createdby": "1",
    "updatedby": "0",
    "shopId": "1",
    "witneesid": "1",
    "op": "",
    "om": "testom"
}

..to the JSONLint validator, you'll see the validation is successful.

Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
0

Your data is coming in wrong. The client should escape the quotes before creating the JSON.

Use JSON.stringify for JavaScript or follow Escape Quotes in Objective-C.

Community
  • 1
  • 1
Dustin Kingen
  • 20,677
  • 7
  • 52
  • 92
0

Instead of getting error on parsing you should take care of quotes in response (i.e., avoid malformed JSON responses). Try taking quotes as:

  ....
  ....
  "lastname":"""", 
  "dob":"8/8/2001",
  "dop":"testplace",
  ....
  ....
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56