Я беру строку и использую $ .parseJSON (string), но продолжаю получать следующую ошибку:
uncaught exception: Invalid JSON: {"0":{"chartHtml":"<p> Slide 1</p> ","presNote":"","chartOrderIndex":0},"1":{"chartHtml":"<p> Slide 2</p> ","presNote":"","chartOrderIndex":1},"2":{"chartOrderIndex":2},"3":{"chartHtml":"<p> e 3</p> ","presNote":"","chartOrderIndex":3},"4":{"chartHtml":"<p> Slide 4</p> ","presNote":"","chartOrderIndex":4},"5":{"chartHtml":"<p> Slide 5</p> ","presNote":"","chartOrderIndex":5},"6":{"chartOrderIndex":6}}
Результаты Firebug во время отладки после запуска slideJson.d:
>>> slideJson.d
"{"0":{"chartHtml":"<p> Slide 1</p> ","presNote":"","chartOrderIndex":0},"1":{"chartHtml":"<p> Slide 2</p> ","presNote":"","chartOrderIndex":1},"2":{"chartOrderIndex":2},"3":{"chartHtml":"<p> e 3</p> ","presNote":"","chartOrderIndex":3},"4":{"chartHtml":"<p> Slide 4</p> ","presNote":"","chartOrderIndex":4},"5":{"chartHtml":"<p> Slide 5</p> ","presNote":"","chartOrderIndex":5},"6":{"chartOrderIndex":6}}"
Вот некоторые из призывов десериализовать JSON:
function (slideJson) {
var slideObj, jsonStr;
if (slideJson.d) {
slideObj = $.parseJSON(slideJson.d);
Ajax-вызов для получения Json с типом контента:
$.ajax({
url: 'Someurl',
type: "POST",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) { somenamespace.loadSlides(data); }
});