32

我使用 $.ajax() 从 POST 请求中收到此响应:

{"command": 6,"log_size":50,"log":[
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 1047161877,"to": 0},
    {"type": 30,"tag": " __START__","sensors": "00","ti": 0000011410,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 0000011411,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 0000011411,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 0000011412,"to": 0},
    {"type": 30,"tag": " __START__","sensors": "00","ti": 1047215799,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 1047215799,"to": 0},
    {"type": 30,"tag": " __START__","sensors": "00","ti": 1047218051,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 0000002598,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 1047068795,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 1047068796,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 1047071223,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 1047071224,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 1047071225,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 0000000010,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 0000000012,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0C","ti": 1047130533,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 0000000026,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 0000000180,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 0000000206,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "09","ti": 0000000212,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "08","ti": 0000000383,"to": 0},
    {"type": 30,"tag": " __START__","sensors": "00","ti": 0000001562,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0A","ti": 0000001563,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 0000001564,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0D","ti": 1047161632,"to": 0},
    {"type": 30,"tag": " __START__","sensors": "00","ti": 1047161875,"to": 0},
    {"type": 30,"tag": "*NETEVENT*","sensors": "0B","ti": 1047161876,"to": 0}
],
"response":"ok"}

对于IE工作正常,在Chrome中出现"Syntax error: unexpected number",在Firefox中消息是"SyntaxError: JSON.parse: expected ',' or '}' after property value in object"

在各种在线 JSON 解析器和验证器中,响应的格式似乎没问题,但在 Firefox 和 chrome 中不起作用。

知道为什么会这样吗?

4

2 回答 2

58
于 2013-03-08T14:28:41.540 回答
-2

去掉json中数字前面的0

于 2020-01-08T07:28:27.287 回答