Javascript source JSON help

I have a JSON data array that

[ [[2, 5], [6, 10], [10, 7], [11, 15]],
  [[0, 9], [1, 16], [3, 19], [4,  15]],
  [[0, 7], [5, 16], [8, 17], [12, 19]] ]

but when I try to get the first array [[2, 5], [6, 10], [10, 7], [11, 15]]using jsonData[0], I get the data as 2,5,6,10,10,7,11,15.

I would like to receive the data in JSON format, and not in plain text format. Any ideas?

+3
source share
2 answers

You ask how to convert it to a JSON string, and not just get the default behavior for the array? If so, you should simply do:

JSON.stringify(jsonData[0])

Or whatever you want to pull

+1
source

. jsonData[0], .

console.log(jsonData[0]), .

, .

var a = [[[2, 5], [6, 10], [10, 7], [11, 15]],[[0, 9], [1, 16], [3, 19], [4, 15]],[[0, 7], [5, 16], [8, 17], [12, 19]]];

alert(a[0]);       // 2,5,6,10,10,7,11,15

console.log(a[0]); // [[2, 5], [6, 10], [10, 7], [11, 15]]

. .

, " JSON" . JavaScript.

+3

Source: https://habr.com/ru/post/1762010/


All Articles