Here's what is happening with your code: you're accessing the first element of a JSON string, so my guess is you will get its first character: [.
You need to convert your string into an actual array before accessing it!
Use JSON.parse:
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
For example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON string, so my guess is you will get its first character: [.
You need to convert your string into an actual array before accessing it!
Use JSON.parse:
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
For example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON string, so my guess is you will get its first character: [.
You need to convert your string into an actual array before accessing it!
Use JSON.parse:
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
For example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON objectstring, so my guess is you will get its first character: [.
You need to convert your objectstring into an actual array before accessing it!
Use JSON.parse, forJSON.parse :
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
For example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON object, so my guess is you will get its first character: [.
You need to convert your object into an actual array before accessing it!
Use JSON.parse, for example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON string, so my guess is you will get its first character: [.
You need to convert your string into an actual array before accessing it!
Use JSON.parse :
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
For example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])
Here's what is happening with your code: you're accessing the first element of a JSON object, so my guess is you will get its first character: [.
You need to convert your object into an actual array before accessing it!
Use JSON.parse, for example you can do:
const json = '[[{"firstname": "Micheal", "lastname": "Brown"}], [{"car": "Ford", "model": "Fiesta"}]]'
// that's what you have
console.log(json[0])
// that's what you want
array = JSON.parse(json)
console.log(array[0])