0

I have difficulty understanding between this type of JSON objects. They work differently in my code.

What is the difference between this: (A)

[
    [
        { department: 'A', name: 'santos' },
        { department: 'B', name: 'suarez' },
        { department: 'C', name: 'domingo' },
        { department: 'A', name: 'james' },
        { department: 'B', name: 'black' }
    ]
];

And this: (B)

[
    { department: 'A', name: 'santos' },
    { department: 'B', name: 'suarez' },
    { department: 'C', name: 'domingo' },
    { department: 'A', name: 'james' },
    { department: 'B', name: 'black' }
];

Aside from the extra brackets on each sides.

I have to put JSON.stringify(value) just to read the one in set (A). and I get this extra elements

"$$hashKey":"object:23"
Omar Einea
  • 2,478
  • 7
  • 23
  • 35
  • 1
    Possible duplicate of [What is the $$hashKey added to my JSON.stringify result](https://stackoverflow.com/questions/18826320/what-is-the-hashkey-added-to-my-json-stringify-result) – Aleksey Solovey Jan 17 '18 at 11:36
  • [there is no such thing as JSON objects](http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/). Apart from the "extra brackets", those JS objects seem exactly the same (unless there are hidden characters) – Kaddath Jan 17 '18 at 11:36

1 Answers1

0

A- Is a multi-dimensional

B - Is a two dimensional array

Go to this if you want Convert object to multi-dimensional array - JavaScript

Go to this if you want How can I make two dimensional array with JSON objects into single array in javascript?

And kindly take a look for this What is JSON and why would I use it?

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234