Skip to content

Latest commit

 

History

History
136 lines (116 loc) · 2.55 KB

README_json.md

File metadata and controls

136 lines (116 loc) · 2.55 KB

Experiments with JSON

This effort resulted in xonixx/gron.awk.

JSON

{
  "total": 57,
  "page": [
    {
      "firstName": "John",
      "lastName": "Doe",
      "age": 25,
      "active": true,
      "hobby": "football"
    },
    {
      "firstName": "Jane",
      "lastName": "Smith",
      "age": 24,
      "active": false,
      "hobby": null
    }
  ]
}

JSON assembler

object
    key
    "total"
    number
    57

    key
    "page"
    array
        object
            key
            "firstName"
            string
            "John"

            key
            "lastName"
            string
            "Doe"

            key
            "age"
            number
            25

            key
            "active"
            true

            key
            "hobby"
            string
            "football"
        end_object

        object
            key
            "firstName"
            string
            "Jane"

            key
            "lastName"
            string
            "Smith"

            key
            "age"
            number
            24

            key
            "active"
            false

            key
            "hobby"
            null
        end_object
    end_array
end_object

Keywords

object       # {
end_object   # }
array        # [
end_array    # ]
key          # "key":
string       # "value"
number       # 123
true         # 
false        # 
null         # 

Links

Test the whole thing

cat test_data/1.json \
  | awk -f json_parser.awk \
  | awk -f json_gron.awk \
  | grep "org." \
  | awk -f gron_parser.awk \
  | awk -f nat_sort.awk -f ungron.awk \
  | Indent=2 awk -f json_compile.awk