Djed /dʒɛd/ (Djevko Data Format) is a data format compatible with JSON: the two can be translated into each other.
Djed supports JSON literals which allow embedding JSON documents verbatim as values into Djed.
Djed is more minimal and lightweight than JSON, while being more powerful and flexible at the same time.
Djed is human-friendly and ergonomic.
Like JSON, Djed is suitable for data-interchange (thanks to being efficient to process by machines).
Unlike JSON, Djed is also good for configuration (thanks to its support for comments and ignored entries).
Also unlike JSON, Djed lends itself naturally to streaming (no need for JSON Lines and similar JSON extensions).
The JavaScript library can also handle Infinity and NaN as numbers.
This is a comment
title [djed example]
owner [
name [tester]
dob [`2020-08-05T20:30:01+09:00[Asia/Tokyo][u-ca=japanese]`]
]
database [
enabled [true]
quoted [`true`]
ports [
[8000]
[8001]
[8002]
]
data [ [[delta] [phi]] [3.14] ]
temp targets [ cpu [79.5] case [72.0] ]
]
servers [
alpha [
ip [10.0.0.1]
role [frontend]
]
beta [
ip [10.0.0.2]
role [backend]
]
;discarded key [[with][a][value]]
;[discarded section]
]
embedded documents [
some json [[json]`
{
"id": "b3df0d",
"count": 55,
"props": {
"return code": "59503a7b",
"status": "pending"
},
"associated ids": [
"3adf7c",
"ff0df7",
"3aa670"
],
"parent": null
}
`]
more json [[json]`55`]
json string [[json]`"\n\tsomething\u0000"`]
json array [[json]`[1, 2, 3, 4, null]`]
]
comment
`key` [
comment
`value`
]
key2 [
yaba
daba
seq
]
`` [empty]
inf [Infinity]
nan [NaN]
comment c
k`key k`k
[v`value v`v]
A value starts either at the beginning of a file (the top-level
value) or after a [
(a nested value).
A value ends either at the end of a file (the top-level value) or
before a ]
(a nested value).
The following characters are considered whitespace:
' ' (0x20) space (SPC)
'\t' (0x09) horizontal tab (TAB)
'\n' (0x0a) newline (LF)
'\v' (0x0b) vertical tab (VT)
'\f' (0x0c) feed (FF)
'\r' (0x0d) carriage return (CR)
[
]
or
`
, are treated as comments and ignored:
this is a comment
and so is this
this is not a comment [
this is also not a comment ]
neither is this `
See also ignored entries for an
alternative to comments which allows [`]
.
`
is called quoted text.
`my text`
"my text"
[
or
]
.
`my text with [brackets]
spanning multiple
lines`
"my text with [brackets]\nspanning multiple\nlines"
Quoted text can also contain `
provided that it is not
followed by zero or more whitespace characters and then [
or ]
, all on the same line.
`invalid quoted text [`]`
error
`more invalid text ` [`
error
'''
.
Repeat '
as many times as needed for the text to parse
correctly:
'`now it's valid [`]`'
"now it's valid [`]"
''`also valid [`]`''
"also valid [`]"
'''`valid as well ` [`'''
"valid as well ` ["
Quoted text preceded by any entries other than
the [json]
entry is an error.
[xml]`error`
error
key [value]
key 2 [value 2]
`error`
error
[json]
[entry] is interpreted
as a JSON literal. It must contain valid JSON.
[json]`{"key": 123}`
{"key": 123}
`text`
"text"
`\n\r\f\u0000`
"\\n\\r\\f\\u0000"
[json]`"\n\r\f\u0000"`
"\n\r\f\u0000"
An unquoted line of text may occur at the end of a value.
If it is not empty and is preceded by any entries, it causes an error.
[entry]
error
error
key [value]
error
error
relevant part
The line here is relevant part
, without the surrounding
whitespace.
An unquoted line which contains only whitespace is considered empty.
An [unquoted line] not preceded by any entries may be a keyword, translated into a specific JSON value.
The keywords are as follows.
true
and false
-> JSON true
and false
true
and
false
, commonly interpreted as booleans, are translated
into their JSON equivalents.
true
true
false
false
null
-> JSON
null
null
is translated into
JSON null
.
null
null
seq
->
empty JSON arrayseq
is translated into
an empty JSON array.
seq
[]
map
->
empty JSON objectmap
is translated into
an empty JSON object.
map
{}
123
123
When using Djed directly from JavaScript, Infinity
and
NaN
are translated to proper IEEE754 values.
When translating to JSON, by default they are converted to
null
, in conformance with semantics of
JSON.stringify
.
TODO: An option shall be provided to convert Infinty
and
NaN
to strings "Infinity"
and
"NaN"
instead.
There are two kinds of entries: key-value entries and value entries.
Key-value entries look like this:key [value]
[value]
Concatenating key-value entries and value entries (mixing them together) is an error:
key 1 [value 1]
[value 2]
key 2 [value 3]
[value 4]
;
:
;ignored key [ignored value]
;`ignored key` [ignored value]
;[ignored value 2]
;something [something]
[value 1]
[value 2]
;[something]
key 1 [value 1]
key 2 [value 2]
Ignored entries can be used as multiline documentation comments and to temporarily exclude certain values from being considered (useful for configuration).
Ignored entries can also be used in combination with quoted text as comments which allow[`]
:
;[`[ignored]`]
;['`ignored [`]`']
$reserved key [reserved value]
$`reserved key` [reserved value]
$[reserved value 2]
Key-value entries can be concatenated together to form maps:
key 1 [value 1]
key 2 [value 2]
key 3 [value 3]
{
"key 1": "value 1",
"key 2": "value 2",
"key 3": "value 3",
}
key 1 [value 1] key 2 [value 2] key 3 [value 3]
Map keys must be unique, so this is an error:
key 1 [value 1]
key 1 [error]
error
key 1 [value 1]
key 1[value 2]
`
:
` key 1 ` [value 1]
{
" key 1 ": "value 1"
}
`` [value of empty key]
{
"": "value of empty key"
}
`multiline
key` [value]
{
"multiline\nkey": "value"
}
map
:
map
{}
key [map]
{
"key": {}
}
seq
s for short):
[value 1]
[value 2]
[value 3]
[
"value 1",
"value 2",
"value 3"
]
[value 1][value 2][value 3]
[value 1]
[value 2] [value 3]
seq
:
seq
[]
key [seq]
{
"key": []
}
key [
[value 1]
[value 2]
[[1][2][3]]
[
key 1 [value 1]
key 2 [value 2]
]
]
{
"key": [
"value 1",
"value 2",
[1, 2, 3],
{
"key 1": "value 1",
"key 2": "value 2"
}
]
}