Reputation: 13
I have a php file returning this valid Json data, stored in a javascript variable named "json".
[
"564654.56464",
"848492.25477",
"918821.54471"
]
I try to display it in javascript with :
var object = JSON.parse(json);
document.write(object. ..... );
i don't know what to add here since my Json is not like {"attribute":"value","attribute2":"value2"
Upvotes: 0
Views: 72
Reputation: 3489
You can encode your PHP file along with a json header. I guess that should do the trick!
header('Content-Type: application/json');
echo json_encode($array);
Upvotes: 1