0

I'm seeing JSON presented in a couple of different formats/styles, and I'm wondering if there are any standard names for these different formats/styles. My searches haven't turned up any info - I'd appreciate anything anyone could share.

Format 1:

{
    "KEYS": ["first", "last", "middle", "age"],
    "VALUES": [
        ["joe", "smith", "a", 34],
        ["mary", "morris", "p", 65],
        ["phillip", "jones", "a", 33]
    ]
}

Format 2:

[{
    "first": "joe",
    "last": "smith",
    "middle": "a",
    "age": 34
}, {
    "first": "mary",
    "last": "morris",
    "middle": "p",
    "age": 33
}, {
    "first": "phillip",
    "last": "jones",
    "middle": "a",
    "age": 33
}]
Jeff Levine
  • 2,083
  • 9
  • 30
  • 38
  • Sublime formats JSON like the first section and Sublime rules, so therefore the first statement wins. :) – Jimmy Scray Mar 17 '16 at 00:05
  • I'm more talking about the arrangement of data as an array of keys and arrays of values vs. sets of key/value pairs. – Jeff Levine Mar 17 '16 at 00:08
  • Ah gotcha. I think this is use case dependent since you would have to look into what is rendering the JSON. Look into if it is more expensive/usable to create an object vs having mirrored arrays. I prefer objects but that is just me. – Jimmy Scray Mar 17 '16 at 00:13
  • Thanks - I understand the merits of each structure, just wondering if each structure has a commonly used name to refer to it. – Jeff Levine Mar 17 '16 at 00:18

3 Answers3

0

The first JSON structure is more suitable for table representation while the second is a classic JSON representation of a list of objects.

Yoram
  • 572
  • 6
  • 21
0

The second format seems much more standard, as it's using key-value pairs the way JSON intends. It's the format produced by d3.dsv for instance.

It's a bit hard to be definitive though.

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
0

A colleague suggested "tabular" for format 1 (I also like "mirrored arrays") and "standard" for format 2. Unless someone knows of some more formal/common names, I'll stick with these for now.

Jeff Levine
  • 2,083
  • 9
  • 30
  • 38