Skip to content

jaspeen/thjson-go

 
 

Repository files navigation

thjson-go

Experiment to add type qualifiers for hjson format. Based on https://github.com/hjson/hjson-go hjson parser.

Idea is to have equivalent of yaml tags to annotate objects with some word what can be interpreted by parser client to construct appropriate object from plain map. Following thjson:

  {
    field1: value
    field2: @mytype {
       typeField1: val
       typeField2: val
    }
    array: [ 
      @mytype2 {
         field: val
      }
      @mytype3 {
         field: val
      }
    ]
  }

will be translated to following structure:

  {
    "field1": "value"
    "field2": {
       "@type": "mytype",
       "typeField1": "val",
       "typeField2": "val"
    }
    "array": [ 
       {
         "@type": "mytype2",
         "field": "val"
      },
      {
         "@type": "mytype2",
         "field": "val"
      }
    ]
  }

Then @type property can be used to reconstruct object type

Install

Make sure you have a working Go environment. See the install instructions.

To install thjson run:

go get -u github.com/jaspeen/thjson-go

Usage

See https://github.com/hjson/hjson-go

About

Hjson for Go with type structures support

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.3%
  • Shell 3.7%