I'm looking at an ajax response and it contains a large json object, which contains an array, which contains json data like this:
"chat": {
"chat": [
{
"chat_type": 0,
"chat_id": 445473683,
"chat_name": "system",
etc,
etc,
"chat_talk": "Chat+messages+here"
},
{
//Another chat message
}
]
}
There are dozens of json entries inside the chat array, which only seems to have the 1 element. There are a few "chat_types" 0, 1, and 2. Now, what I want to do is select only chat entries that are of type 2 and do NOT have system as the "chat_name".
But the whole object in an array in an object confuses the heck out of me. How would I accomplish this?
EDIT: Code so far -
function modChat (clickEvent) {
var chatHistory = [];
var extraData = '{"planet_id":"6_300_6","item_config_version":"' + getChatTimeStamp() + '","count":20,"tick":"-1","language":"en"}';
//$("#chatBody").html(extraData);
runRequest(extraData, gameDataURL, function(response) {
var results = [];
var chats = JSON.stringify(response.chat.chat);
for (var i = 0; i < chats.length; i++) {
if (chats[i].chat_type == 2 && chats[i].chat_name != "system") {
results.push(chats[i]);
}
}
$("#chatBody").val(chats);
});//End postRequest
}