0
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);

我的输入字符串是 :::::

{
  "function":"addwhy",

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


}

我的代理确实也尝试将其转换为 UTF8 格式,但是我的代码在用于解析器时生成了错误。

4

3 回答 3

1

它应该只是一个反斜杠,如...

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

如果您添加此 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"
}

..到JSONLint 验证器,你会看到验证成功。

于 2013-09-18T12:29:23.107 回答
0

你的数据有误。客户端应在创建 JSON 之前转义引号。

用于JSON.stringifyJavaScript 或遵循 Objective-C 中的转义引号

于 2013-09-18T12:50:17.733 回答
0

而不是在解析时出错,您应该注意响应中的引号(即,避免格式错误的 JSON 响应)。尝试将引号作为:

  ....
  ....
  "lastname":"""", 
  "dob":"8/8/2001",
  "dop":"testplace",
  ....
  ....
于 2013-09-18T12:53:00.780 回答