2011-10-13 5 views
0

스타일 태그가 포함 된 JSON 응답이 있습니다. jsonlint로 유효성을 검사하면 유효하지 않은 JSON이 표시됩니다. 아무도 내게 뭐가 잘못이 도와주세요. 파이어 폭스는 올바른 결과를 제공하는 코드를 실행하려고 할 때. 그러나 IE만이 문제를 일으키고 있습니다. 예를 들어json 응답의 스타일 태그 즉,?

:

{ 
"contentHTML": "<style type=\"text/css\">\nbody\n{\n margin:0; 
    \n \n}\n\n.centerComponents\n{\n margin:auto; 
    \n text-align:left; 
    \n}\n\n#element1\n{\n width:984px; 
    \n}\n\n#c1315402137156\n{\n width:984px; 
    \n min-height:98px; 
    \n height:auto !important; 
    \n height:98px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137155\n{\n width:984px; 
    \n min-height:150px; 
    \n height:auto !important; 
    \n height:150px; 
    \n margin:2px 0 0 0; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#element2\n{\n width:984px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#element3\n{\n width:243px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137154\n{\n width:243px; 
    \n min-height:547px; 
    \n height:auto !important; 
    \n height:547px; 
    \n margin:20px 0 0 0; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137157\n{\n width:100px; 
    \n min-height:100px; 
    \n height:auto !important; 
    \n height:100px; 
    \n margin:27px 138px 0 5px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#element4\n{\n width:740px; 
    \n margin:0 0 0 1px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137257\n{\n width:740px; 
    \n min-height:5px; 
    \n height:auto !important; 
    \n height:5px; 
    \n margin:30px 0 0 0; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137158\n{\n width:740px; 
    \n min-height:423px; 
    \n height:auto !important; 
    \n height:423px; 
    \n margin:1px 0 0 0; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n#c1315402137159\n{\n width:740px; 
    \n min-height:994px; 
    \n height:auto !important; 
    \n height:994px; 
    \n display:inline; 
    \n float:left; 
    \n}\n\n<\/style>" 
} 

답변

1

난 당신이 JSON 내에서 새로운 라인 (실제 줄 바꿈이 아닌 \n 순서)를 가지고 있기 때문에 그것의 생각이되는 자바 스크립트, 즉 허용하지 않는다.

잘못된 :

var a = "Hello 
      World"; 

유효한 :

var a = "Hello World"; 
+0

이 올바른지; 하지만 "JSON이기 때문에 허용되지 않습니다"(JavaScript에서도 마찬가지 임). 그것은 허용되기 전에 JS에 전달 될 필요조차 없습니다. Firefox는 필자가 찾은 오류에 대해 "용서하는"것이므로 도움보다 고통 스러울 수 있습니다. –

관련 문제