Why is this an invalid JSON, I'm also tried putting quotes to the key and doesn't work.
{
Nombre: “Manzana”,
Imagen: “./img/imagen_manzana.jpg”,
Descripción: “Manzana rica”,
PrecioKG: 24,
Iva: 16,
Inventario:30
},
{
Nombre: “Naranja”,
Imagen: “./img/imagen_naranja.jpg”,
Descripción: “Naranja rica”,
PrecioKG: 14,
Iva: 16,
Inventario: 27
}
For several reasons:
The keys are not in double quotes.
The strings are quoted with "fancy quotes" (“
), not correct quotes "
.
You have two top-level values. There can only be one top-level value. If you want two objects, you need to wrap them in an array.
http://jsonlint.com (no affiliation) and other such sites can help you with these things.
Minimal fix:
[
{
"Nombre": "Manzana",
"Imagen": "./img/imagen_manzana.jpg",
"Descripción": "Manzana rica",
"PrecioKG": 24,
"Iva": 16,
"Inventario": 30
},
{
"Nombre": "Naranja",
"Imagen": "./img/imagen_naranja.jpg",
"Descripción": "Naranja rica",
"PrecioKG": 14,
"Iva": 16,
"Inventario": 27
}
]