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

324
Vistas
JSON not parsing correctly using JSON.parse but $.parseJSON works

In JS I have a string variable as follows: Text JSON Data:

[{ "id" : "3", "parent" : "2", "text" : "Lack of Survey Information" },{ "id" : "4", "parent" : "3", "text" : "Lack of Surveyor Resource" },{ "id" : "5", "parent" : "3", "text" : "Land access unavailable" },{ "id" : "2", "parent" : "1", "text" : "Design Incorrect" },{ "id" : "1", "parent" : "16", "text" : "Abortive Work" },{ "id" : "6", "parent" : "1", "text" : "Wrong design info used in construction" },{ "id" : "16", "parent" : "#", "text" : "a" }]

This is output from the following code:

            console.log("Text JSON Data:"+strJSON)
        var objJSON=$.parseJSON(strJSON)
        var objJSON=JSON.parse(strJSON)

It parses using $.parseJSON but does not parse using JSON.parse (I get a bizarre "Uncaught TypeError: JSON.parse is not a function" error though it clearly is). I am using Chrome. It gets weirder, when I just use $.parseJSON successfully and then use JSON.stringify on the returned JSON object it crashes and also throws up an error.

What is weird is that I pass several other JSON strings to this function and they are parsed fine. I thought it might be something to do with the '#' symbol but it seems to parse OK in JSFiddle. I know when using VBA that sometimes an error code is triggered for a line of code when in fact the error is caused by something else. I am wondering if that is what is going on here.

What I need to understand is why this particular string is triggering the bizarre errors.

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