CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 43
Releases: hjson/hjson-go
v4.5.0
f321965
Compare
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
Assets 30
- 973 KB
2025-04-21T09:02:09Z - 1 MB
2025-04-21T09:02:08Z - 969 KB
2025-04-21T09:02:08Z - 1010 KB
2025-04-21T09:02:08Z - 956 KB
2025-04-21T09:02:07Z - 1010 KB
2025-04-21T09:02:07Z - 945 KB
2025-04-21T09:02:06Z - 964 KB
2025-04-21T09:02:06Z - 1020 KB
2025-04-21T09:02:05Z - 952 KB
2025-04-21T09:02:05Z -
2025-04-20T16:01:38Z -
2025-04-20T16:01:38Z - Loading
v4.4.0
Compare
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()
.
Assets 30
v4.3.1
60737ac
Compare
Any control chars in map keys are now escaped in Hjson and JSON output.
Tested on Go 1.12 - 1.21
Assets 30
v4.3.0
0cb03b8
Compare
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
Assets 30
v4.2.0
905a757
Compare
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
Assets 30
v4.1.0
88088fd
Compare
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
Assets 30
v4.0.0
9bab3c4
Compare
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
totrue
. - 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.
Assets 30
v3.3.0
ef94b56
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/github.com/hjson/hjson-go
or other folder dictated by the local Go environment.
Assets 5
v3.2.0
e669f6b
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.
Assets 5
v3.1.1
Compare
Releases now contain hjson-cli binaries for Linux, macOS and Windows.