У меня есть объект json, который я загружаю из WordPress с помощью плагина JSON API.Когда я загружаю объект json и пытаюсь выйти из его частей, кажется, что он обрабатывает каждый отдельный символ как свой собственный объект, поэтому цикл возвращает мне пару тысяч объектов, каждый из которых содержит элемент, состоящий из одного символа.Это мой первый раз, когда я использую json, так что идите, если я пропускаю шаг здесь.это код, который я использую до сих пор.
function getProjInfo(theId){
$.ajax({// calling the ajax object of jquery
type: "GET",// we are going to be getting info from this data source
url: 'http://testing.charter21.com/api/get_post/?post_id='+ theId,//the datasource
dataType: "application/json",
success: function(data){
parseJson(data);
}, // what happens when it is successful at loading the XML
error: function(){
alert("error");
}
});
}//end of the function
function parseJson(inData){
postInfo = inData;
$.each(postInfo, function(index, value){
console.log(this);
});
}
JSON выглядит так:
{
"status": "ok",
"count": 10,
"count_total": 19,
"pages": 2,
"posts": [
{
"id": 175,
"type": "post",
"slug": "home-page-slider",
"url": "http:\/\/testing.charter21.com\/uncategorized\/home-page-slider\/",
"status": "publish",
"title": "Home Page slider",
"title_plain": "Home Page slider",
"content": "<p>The cImages in here are the images that are in the slider on the home page this content in this box will not show up. Its only here as a guide.<\/p>\n",
"excerpt": "The cImages in here are the images that are in the slider on the home page this content in this box will not show up. Its only here as a guide.",
"date": "2011-01-25 10:40:25",
"modified": "2011-01-25 10:40:25",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "admin",
"name": "admin",
"first_name": "",
"last_name": "",
"nickname": "admin",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "open"
}
так что в основном вместо того, чтобы давать мне статус"в качестве ключа и" ОК "в качестве значения, я получаю" s "в качестве объекта с индексом 0, который имеет значение" s "для каждого отдельного символа в объекте json.Буду признателен за любую помощь в этом вопросе.