2022-08-07 12:56:59 +03:00
|
|
|
---
|
2022-08-08 18:37:11 +03:00
|
|
|
language: Hjson
|
2022-08-07 12:56:59 +03:00
|
|
|
filename: learnhjson.hjson
|
|
|
|
contributors:
|
|
|
|
- ["MrTeferi", "https://github.com/MrTeferi"]
|
|
|
|
lang: en
|
|
|
|
---
|
|
|
|
|
2022-08-08 18:37:16 +03:00
|
|
|
Hjson is an attempt to make [JSON](https://learnxinyminutes.com/docs/json/) more human readable.
|
2022-08-07 12:56:59 +03:00
|
|
|
|
2022-08-08 18:37:20 +03:00
|
|
|
Hjson is a syntax extension to JSON.
|
2022-08-07 12:56:59 +03:00
|
|
|
It's NOT a proposal to replace JSON or to incorporate it into the JSON spec itself.
|
|
|
|
It's intended to be used like a user interface for humans,
|
|
|
|
to read and edit before passing the JSON data to the machine.
|
|
|
|
|
|
|
|
Let's take a look at examples to see the key syntax differences!
|
|
|
|
|
2023-03-01 03:00:37 +03:00
|
|
|
```
|
2022-08-07 12:56:59 +03:00
|
|
|
{
|
|
|
|
# Comments are totally supported!
|
|
|
|
|
|
|
|
// With forward slashes too!
|
|
|
|
|
|
|
|
/*
|
|
|
|
Even block style comments, neat!
|
|
|
|
/*
|
|
|
|
|
|
|
|
# Strings do not require quotes!
|
|
|
|
# Just keep it to a single line
|
|
|
|
human: readable
|
|
|
|
quotes: "are fine too"
|
|
|
|
|
|
|
|
# Notice that commas are also not required!
|
|
|
|
# If using commas, strings DO require quotes!
|
|
|
|
object: {
|
2022-08-08 18:37:53 +03:00
|
|
|
name: Hjson
|
2022-08-07 12:56:59 +03:00
|
|
|
properties: [
|
|
|
|
readable
|
|
|
|
exciting
|
|
|
|
fun
|
|
|
|
]
|
|
|
|
with_commas: [
|
|
|
|
"quoted",
|
|
|
|
"quoty",
|
|
|
|
"quote"
|
|
|
|
]
|
|
|
|
details: ["this", "is", "fine", "too"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Multiline quotes with proper whitespace handling are supported!
|
|
|
|
diary:
|
|
|
|
'''
|
|
|
|
I wish JSON was more human readable.
|
|
|
|
If only there was a JSON for my needs!
|
2022-08-08 18:37:30 +03:00
|
|
|
Oh wait.. there is! It's called Hjson.
|
2022-08-07 12:56:59 +03:00
|
|
|
'''
|
|
|
|
|
2022-12-10 18:05:34 +03:00
|
|
|
# Backslashes are interpreted as an escape character ONLY in quoted strings
|
2022-08-07 12:56:59 +03:00
|
|
|
slash: This will not have a new line\n
|
|
|
|
slash-quoted: "This will definitely have a new line\n"
|
|
|
|
|
|
|
|
# Make sure to use quotes when mixing whitespace with important punctuation
|
|
|
|
example1: "If, you're, going, to, comma in a string, use, quotes!"
|
|
|
|
example2: "Also if you want to use {} or [] or any JSON relevant punctuation!"
|
|
|
|
example3: [because, this, is, totally, BROKEN!]
|
|
|
|
example4: this is technically OK though: {}[],:
|
|
|
|
|
2022-08-08 18:37:35 +03:00
|
|
|
# Enjoy working with Hjson!
|
2022-08-07 12:56:59 +03:00
|
|
|
party-time: {
|
2022-08-08 18:37:59 +03:00
|
|
|
Hjson-lovers: [
|
2022-08-07 12:56:59 +03:00
|
|
|
me
|
|
|
|
my mom
|
|
|
|
"my dad"
|
|
|
|
]
|
2022-08-08 18:37:06 +03:00
|
|
|
Hjson-power-level: 9000
|
2022-08-07 12:56:59 +03:00
|
|
|
supported: {
|
|
|
|
python: yes
|
|
|
|
java: yes
|
|
|
|
javascript: yes
|
|
|
|
c++: yes
|
|
|
|
Go: yes
|
|
|
|
C#: yes
|
|
|
|
Rust: yes
|
|
|
|
}
|
|
|
|
partial-support: ["C", "Kotlin", "Ruby", "Rust"]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Further Reading
|
|
|
|
|
2022-08-08 18:37:41 +03:00
|
|
|
* [Hjson.github.io](https://hjson.github.io/) Main Hjson site including editor support, how-to, etc.
|
2022-08-08 18:37:47 +03:00
|
|
|
* [Hjson Packages](https://github.com/hjson/) Various Hjson packages for different applications.
|