Hello I am creating a map in php - by saying map I mean the equivalent of hashmap in Java not something related to the Google API map - and I am trying to parse it using JavaScript through JSON after an AJAX call.
here's the map from php printed by print_r
function:
Array ( [A01] => Array ( ) [A02] => Array ( ) [A03] => Array ( ) [B01] => Array ( [0] => Array ( [0] => 1 [1] => 2014-12-14 [2] => 2014-12-18 [3] => no-show ) [1] => Array ( [0] => 1 [1] => 2014-12-04 [2] => 2014-12-15 [3] => active ) ) [B02] => Array ( ) )
but when I encode it in JSON by using json_encode
it becomes this:
{"A01":[],"A02":[],"A03":[],"B01":[["1","2014-12-14","2014-12-18","no-show"],["1","2014-12-04","2014-12-15","active"]],"B02":[]}
and I try to parse it in JavaScript using the following:
$.ajax({
type: "POST",
url: myurl,
data: { ... }
}).done(function(msg) {
var test = JSON.parse(msg);
alert(test);
});
The resulting alert says:
[object Object]
rather than an array as it is. Can you help me?
edit: After reading comments I figured out that my problem is how to use the Object in order to print it for example like: key->value