Skip to content

Wiki: The concise array style #1

@suntong

Description

@suntong

The jsonfiddle fmt's -s, --concise option will

Compact the top level array into concise array style

So, what is the "concise array style"?

The jsonfiddle fmt's -s, --concise option will compact the top level array onto one line while each one is still on a separated line, like this:

{
  "the_root": [
    {"id":101,"name":"Alpha","data":"Some value 1"},
    {"id":202,"name":"Beta","data":"Another value 2"},
    {"id":303,"name":"Gamma","data":"Third value 3"}
  ]
}

with or without the top "the_root" level, this is called the concise array style in this program.

In concrete example, the jsonfiddle fmt command of:

testIt(t, "FmtConciseA", "fmt", "--concise", "-i", "FmtConciseA.json")

Will gives the result of:

[
{"city":"NYC","name":"Alice"},
{"city":"LA","name":"Bob"},
{"city":"SF","name":"Charlie"}
]

This format allows me to use simple tool like grep to search all records of, say, the LA city.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions