mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
80a70f4fa1
Co-authored-by: Marcel Ribeiro Dantas <ribeirodantasdm@gmail.com>
2.6 KiB
2.6 KiB
language | filename | contributors | lang | |||
---|---|---|---|---|---|---|
Hjson | learnhjson.hjson |
|
en |
Hjson is an attempt to make JSON more human readable.
Hjson is a syntax extension to JSON. 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!
{
# 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: {
name: hjson
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!
Oh wait.. there is! It's called Hjson.
'''
# Backslashes are interpretted as an escape character ONLY in quoted strings
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: {}[],:
# Enjoy working with Hjson!
party-time: {
hjson-lovers: [
me
my mom
"my dad"
]
Hjson-power-level: 9000
supported: {
python: yes
java: yes
javascript: yes
c++: yes
Go: yes
C#: yes
Rust: yes
}
partial-support: ["C", "Kotlin", "Ruby", "Rust"]
}
}
Further Reading
- HJSON.github.io Main HJSON site including editor support, how-to, etc.
- HJSON Packages Various HJSON packages for different applications.