We would like to know how to reformat and output string into array.
<!DOCTYPE html>
<html>
<body>
<a id="test"></a>
<script type='text/javascript'>
var myData = {
"timestamps": [1369008000, 1369094400, 1369180800],
"clicks": [1, 2, 3]
};<!-- w ww .j a v a 2 s .c o m-->
var output = [];
var link = document.getElementById('test');
for (var i = 0, l = myData.timestamps.length; i < l; i++) {
output.push([myData.timestamps[i], myData.clicks[i]]);
}
document.writeln(output);
link.innerHTML = JSON.stringify(output);
</script>
</body>
</html>
The code above is rendered as follows: