Skip to content
Choose a tag to compare

Now uses go.mod. New import path for the package:

import ""

Tested on Go 1.11 - 1.18

Breaking changes

  • Non-exported struct fields are now ignored.
  • Promoted struct fields (fields that belong to embedded structs) are now encoded as direct members on the object into which the fields were promoted. This makes the behavior of hjson.Marshal() the same as the behavior of json.Marshal() in this regard.
  • If a type implements encoding.TextMarshaler but not json.Marshaler then the function MarshalText() will be called on it to get a text representation. Both for values and map keys.
  • \r is no longer removed from strings. If a string contains \r it will not be encoded into a multi-line string but instead a quoted string.
  • Releases now contain the hjson tool for a lot more architectures. The tool is distributed as compressed archives instead of uncompressed executables.
  • hjson.Unmarshal() now converts the Hjson input into JSON and then uses a json.Decoder to unmarshal it. This means that hjson.Unmarshal() now can unmarshal to structs, but also that the destination tree is kept if possible. Values are merged into the destination tree instead of always replacing it at the root.
  • The default value of BracesSameLine in EncoderOptions returned by DefaultOptions() has been changed from false to true.
  • Encoder options AllowMinusZero and UnknownAsNull have been removed. They never had any effect.
  • The flag -allowMinusZero has been removed from the hjson tool. It never had any effect.

New features

  • New functions UnmarshalWithOptions() and DefaultDecoderOptions(). Possible options are UseJSONNumber and DisallowUnknownFields, both having false as default value.
Choose a tag to compare

Fix for building version 3 of hjson-go. Requires export GO111MODULE=auto when building or testing using Go 1.16 or later, and that the module is placed in ~/go/src/ or other folder dictated by the local Go environment.

Choose a tag to compare

Can unpack pointers to pointers to strings.

Added and re-enabled encoder options:

  • EmitRootBraces works again.
  • QuoteAmbiguousStrings can be set to false in order to not quote strings even if they will be identical to numbers, booleans or null.
  • BaseIndentation can be used to add an indentation to every line in the output.
Choose a tag to compare

Releases now contain hjson-cli binaries for Linux, macOS and Windows.

Choose a tag to compare

Implement Marshal for structs, with support for comments in structs:

type foo struct {
  a    A    `comment:"First comment"`
  b    B    `comment:"Second comment"`

Additional minor bug fixes.

  • Fix panic when passing nil to Unmarshal
  • Bug fix for marshal of unsigned types
  • Bug fix for README add closing block for code section
  • Use custom Marshaler if type implements Marshal interface
  • Add unit tests for Marshal. encode.go coverage at 94.9%
Choose a tag to compare
Choose a tag to compare

fix err on bad ML string