Skip to content

v4.3.0

Compare
Choose a tag to compare
@github-actions github-actions released this 11 Dec 11:46
· 5 commits to master since this release
0cb03b8

Two new public structs of interest: hjson.OrderedMap and hjson.Node.

hjson.OrderedMap can be used as destination or source for all Hjson unmarshal and marshal functions (if the root value is a map/object), and also for the unmarshal and marshal functions of the standard package json. hjson.OrderedMap is similar to map[string]interface{}, but preserves key order.

hjson.Node can also be used as destination or source for all Hjson unmarshal and marshal functions, and also for the unmarshal and marshal functions of the standard package json. The struct is simply a wrapper for the actual value and a helper struct containing any comments, allowing comments and custom indentation to be preserved if you read in a document, change a value, and then save the document again. hjson.Node has several convenience functions, for example AtIndex() or SetKey() that can be used when you know that the node contains a value of type []interface{} or *hjson.OrderedMap.

Other changes:

  • Added argument -preserveKeyOrder to the tool hjson-cli
  • Added field DisallowDuplicateKeys (default false, which means that later values overwrite earlier values) to the DecoderOptions struct
  • Added field WhitespaceAsComments (default true) to the DecoderOptions struct
  • hjson-go no longer supports Go 1.11

Tested on Go 1.12 - 1.19