A Go implementation of Hjson, a human-friendly JSON alternative with comments, unquoted strings, and optional commas.
hjson-go is the Go implementation of Hjson (Human JSON), a configuration file format designed to be easy for humans to read and write. It extends standard JSON with features like comments, unquoted strings, and optional commas, making it more suitable for configuration files and manual editing while remaining fully interoperable with JSON.
Go developers who need to write or maintain configuration files, especially those who prioritize human readability and manual editing over strict JSON syntax. It's also for developers building tools that require comment preservation in configuration data.
Developers choose hjson-go because it provides a human-friendly syntax for configuration files without sacrificing compatibility with JSON, offering seamless conversion and a familiar API similar to encoding/json. Its unique ability to preserve comments and key order makes it ideal for configuration files that are both machine-processable and human-editable.
Hjson for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports comments (//, #, /* */), unquoted strings, and optional commas, making config files easier to read and edit manually, as shown in examples like 'rate: 1000' without quotes.
Seamlessly converts between Hjson and JSON using Marshal/Unmarshal functions, ensuring compatibility with existing JSON systems, including the hjson-cli tool for file conversion.
Can read and write comments via hjson.Node, maintaining file layout and whitespace, which is ideal for configuration files that require annotations without data loss.
Provides Unmarshal/Marshal functions similar to encoding/json, including support for structs and custom types with json tags, reducing the learning curve for Go developers.
Unquoted strings that are valid numbers or booleans are parsed as those types when unmarshalling to interface{}, potentially causing unintended data types unless using typed destinations, as warned in the README.
To read comments, you must use hjson.Node as the root destination, which adds complexity with a different data structure (e.g., OrderedMap) and convenience functions, unlike standard Go types.
While it has a CLI tool, many third-party tools and libraries in the Go ecosystem assume standard JSON, potentially requiring conversion steps or limiting seamless integration.
The extended syntax requires more complex parsing than standard JSON, which might introduce slight performance penalties in high-throughput scenarios, though it's optimized for human readability.