Skip to content

v4.0.0

Compare
Choose a tag to compare
@github-actions github-actions released this 23 Jul 18:13
· 12 commits to master since this release
9bab3c4

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

import "github.com/hjson/hjson-go/v4"

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.