To use the nomenclature from the spec, if there are no subjevkos (subtrees) in a jevko (tree), then it is interpreted as a string (which is made from its suffix).
{
"subjevkos": [
{
"prefix": "first name ",
"jevko": {
"subjevkos": [],
"suffix": "John"
}
},
{
"prefix": "\nlast name ",
"jevko": {
"subjevkos": [],
"suffix": "Smith"
}
},
{
"prefix": "\nis alive ",
"jevko": {
"subjevkos": [],
"suffix": "true"
}
},
{
"prefix": "\nage ",
"jevko": {
"subjevkos": [],
"suffix": "27"
}
},
{
"prefix": "\naddress ",
"jevko": {
"subjevkos": [
{
"prefix": "\n street address ",
"jevko": {
"subjevkos": [],
"suffix": "21 2nd Street"
}
}
],
"suffix": "\n"
}
}
],
"suffix": "",
"opener": "[",
"closer": "]",
"escaper": "`"
}
tbh seems like a pita to clean up afterwardsWhat you are getting is the plain Jevko parse tree.
The examples explicitly talk about a format built on top of that. See this answer: https://news.ycombinator.com/item?id=33334314
Jevko itself, defined by the spec, is not the same as a format based on Jevko.
If you use a plain spec-compliant Jevko parser you for this you indeed should have all whitespace included. Although it will look more like this:
{
subjevkos: [
{ prefix: "first name ", jevko: { subjevkos: [Array], suffix: "John" } },
{ prefix: "\nlast name ", jevko: { subjevkos: [Array], suffix: "Smith" } },
{ prefix: "\nis alive ", jevko: { subjevkos: [Array], suffix: "true" } },
{ prefix: "\nage ", jevko: { subjevkos: [Array], suffix: "27" } },
{ prefix: "\naddress ", jevko: { subjevkos: [Array], suffix: "\n" } }
],
suffix: ""
}
Now on top of that you can build a format that specifies what happens to whitespace, etc. Usually you'd want it trimmed if the prefixes mean keys in a map.The simplest format/library that does just that is this:
* https://github.com/jevko/easyjevko.lua
* https://github.com/jevko/easyjevko.js
That will give you the JSON (or equivalent) that you expect (with autotrimmed keys).
Jevko leaves whitespace handling not to clients, but to formats built on Jevko which would be the thing the clients typically use (rather than plain Jevko). Such formats of course should be clearly specified, which is something I hope to get around to soon.
I already have a good candidate format for specifying first, which has 2 implementations:
* https://github.com/jevko/easyjevko.js
* https://github.com/jevko/easyjevko.lua
For more details see also:
Jevko seems "simpler" than traditional syntaxes in the same way that a heap of bricks is simpler than a wall.
This is where the rules for whitespace would be specified. These can then be taken advantage of by tools to reformat, etc.
The simplest format that I came up with and should specify next that will most likely do what you want is Easy Jevko. For details see this rabbit hole: https://news.ycombinator.com/item?id=33337098
For an alternative minimal syntax which is based around whitespace check out:
Taking the example from github page (abbreviated):
why isn't it equivalent to this json? somehow the whitespace is instead implicitly magiced away, but that isn't defined in the grammar anywhere as far as I can see?