json_pure-1.4.6을 사용하고 있는데 Chrome의 SpeedTracer에서 데이터를 파싱하는 데 문제가 있습니다. 특히이 같은 실패 :Ruby JSON 구문 분석기가 공백을 좋아하지 않는다고 정당화 했습니까?
명확의 불완전한 문하지만, 파일 자체는 다음과 같습니다705: unexpected token at '{"type":2147483642,"time":8872.551025390625,"data":{"identifier":1,"time":1295485209.698246,"request":{"url":"http://localhost:3000/login/new","httpMethod":"GET","httpHeaderFields":{"User-Agent":"Mozilla/5.0'
:
{"type":2147483642,"time":8872.551025390625,"data":{"identifier":1,"time":1295485209.698246,"request":{"url":"http://localhost:3000/login/new","httpMethod":"GET","httpHeaderFields":{"User-Agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.634.0 Safari/534.16","Accept":"application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"}},"redirectResponse":{"isNull":true}},"sequence":116}
내가 JSONLint를 통해 실행 시도
하고 불평하지 않았다 : 그것은 공백에 실패 때문에
{
"type": 2147483642,
"time": 8872.551025390625,
"data": {
"identifier": 1,
"time": 1295485209.698246,
"request": {
"url": "http://localhost:3000/login/new",
"httpMethod": "GET",
"httpHeaderFields": {
"User-Agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.634.0 Safari/534.16",
"Accept": "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
}
},
"redirectResponse": {
"isNull": true
}
},
"sequence": 116
}
, 나는 "사용자 에이전트"라인의 공백을 모두 제거 시도 json_pure는 오류없이 구문 분석. 이것은 json_pure 버그입니까?
빌 덕분에 필자는 파서가 구문 분석하려는 내용을 자세히 살펴 봤습니다. 내 문제는 내가 DUMB 실수를 저질렀다고 밝혀졌다. JSON 데이터를 HTML에서 모두 제외하고 하나의 문장으로 처리하려고했습니다. 불행히도, 나는 정규화되지 않은 "분할"을하고 있었기 때문에 모든 줄 바꿈이 아닌 모든 공백으로 나뉘어져있었습니다. 원래 테스트 한 SpeedTrace 데이터에는 혼란을 유발하는 공백이 없었습니다. '분할'로 전환하면 \ n "내 문제가 해결되었습니다. –