Skip to content

Releases

v4.7.1

Choose a tag to compare

@github-actions github-actions released this 06 Sep 16:51
033fae8

Fixes issue where unmarshal (decoding an Hjson input string) would abort with an error message if the input contained "1e" or similar strings that might be interpreted as numbers in scientific notation that are missing their exponent.

Tested on Go 1.12 and 1.27

v4.7.0

Choose a tag to compare

@github-actions github-actions released this 22 Aug 11:03
53e5da2

In order to avoid stack overflows now throws an error if trying to marshal (create Hjson output) from a tree deeper than 10000 levels

Tested on Go 1.12 and 1.27

v4.6.0

Choose a tag to compare

@github-actions github-actions released this 25 Jan 20:45
23908b1

Fixes issue with decoding into struct fields of unknown type after fields of known type in the same struct.

New parameter -preserveComments for the command line tool hjson-cli.

Tested on Go 1.12 and 1.25

v4.5.0

Choose a tag to compare

@github-actions github-actions released this 21 Apr 09:18
f321965

In order to avoid stack overflows now throws an error if input Hjson contains a tree deeper than 10000 levels

The file go.mod now specifies go 1.12 instead of go 1.11

Tested on Go 1.12 and 1.24

v4.4.0

Choose a tag to compare

@github-actions github-actions released this 07 Dec 14:31

Slightly changed behavior for unmarshalling "null" into a string destination: if the value is "null" without quotes and the destination is a pointer then the pointer is set to nil instead of a pointer to the string "null", even if the destination is a pointer to a string or a type that implements UnmarshalText().

v4.3.1

Choose a tag to compare

@github-actions github-actions released this 23 Oct 16:32
60737ac

Any control chars in map keys are now escaped in Hjson and JSON output.

Tested on Go 1.12 - 1.21

v4.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Dec 11:46
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

v4.2.0

Choose a tag to compare

@github-actions github-actions released this 26 Sep 23:31
905a757

Retain key order in objects for UnmarshalJSON() and MarshalJSON() so that implementations of ordered maps can work.

New interface ElemTyper allows custom containers implementing UnmarshalJSON() to let hjson.Unmarshal() know what type of elements they will contain, so that hjson.Unmarshal() can unmarshal numbers, booleans and null into strings if needed by the custom container.

Tested on Go 1.11 - 1.19

v4.1.0

Choose a tag to compare

@github-actions github-actions released this 04 Sep 16:06
88088fd

Type ambiguity due to quoteless strings can now be avoided by using typed destinations when unmarshalling. A string destination will receive a string even if the quoteless string also was a valid number, boolean or null. Previously an error would have been returned, for example "cannot unmarshal number into Go value of type string".

Tested on Go 1.11 - 1.19

v4.0.0

Choose a tag to compare

@github-actions github-actions released this 23 Jul 18:13
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.
⌂ 换网址