Pregunta

I'm having a very hard time to find a JSON.stringify bug.

I have an object with the following structure:

var test_object = {
    id  : 0,
    type: 'root',

    related_dropzone_id   : 0,
    related_dropzone_order: 0,

    options : {},
    children: []
}

where children is an array of objects defined as test_objects like:

[
      12387192837: test_object_a,
      12387192838: test_object_b
]

of course, with different values for its properties.

When I do a console.log(top_most_object), the console throws the correct object nesting with its properties but when I output a console.log(JSON.stringify(top_most_object)) then it shows a string with the topmost children array as empty: [] aka: truncated.

The call to JSON.stringify doesn't throw any error so I don't know what is the issue with this.

So the question is, how can I debug the issue here?

¿Fue útil?

Solución

You are missing brackets for the objects.

[
      {12387192837: test_object_a},
      {12387192838: test_object_b}
]

Other than that the stringify works for me.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top