Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
Unexpected token ":" error after fetching json file

I am trying to use fetch to import a local json file in JavaScript but I keep getting the error for the 2nd line of the json file:

Uncaught SyntaxError: Unexpected token ":"

Here is my json file:

{
    "items": [
        {
            "key 1": "abc",
            "key 2": {
                "xyz": [
                    {
                        "name": "abc",
                        "version": "1.0.0",
                    },
                    ...                
                ]
            },
            "key 3": {
                "...": [
                    {
                        ...
                    },
                    ...                
                ]
            },
        },
        ...
    ]
}

I've used an online json validator, and confirmed that my json.

Here is my JavaScript code:

<script src="file.json">
    fetch("./file.json")
        .then(res => res.json())
        .then(data => console.log(data))
        .catch(err => console.log(err))
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda