QUEry, URL-Encodable ECMAScript Object Notation
Online live compiler | Implementations
QUESON is a URL-friendly alternative notation for JSON.
This JSON:
{
"Hello!": ["It looks", "like this."],
"Kind of weird": {
"but better than": "the alternative!"
}
}
which minified and URL-encoded looks like this:
%7B%22Hello%21%22%3A%5B%22It%20looks%22%2C%22like%20this.%22%5D%2C%22Kind%20of%20weird%22%3A%7B%22but%20better%20than%22%3A%22the%20alternative%21%22%7D%7D
in QUESON, looks like this instead:
X.w.Hello!.w-I.w.It_looks.w_w.like_this...w.I_w.Kind_of_weird.w-X.w.but_better_than.w-w.the_alternative!.w.X.X
- Strings are enclosed in
w.
.w
(becausew
kind of looks like"
). - Arrays are enclosed in
I.
.I
(becauseI
kind of looks like[
and]
), with elements separated by_
. - Objects are enclosed in
X.
.X
(becauseX
kind of looks like{
and}
), with keys separated from values by-
, and properties separated by_
. - Spaces in strings are represented as
_
; the escape character is.
. - Numbers, booleans and null stay mostly the same.
There's a PEG.js grammar that produces a JSON string that serves as spec:
There are multiple alternatives for URL-friendly JSON representations:
QUESON is different because:
- A QUESON value fits in a single query parameter, so you can use other query parameters.
- QUESON delimiters don't need percent-encoding, so the structure can be legible by a human, if you squint (most non-alphanumerical characters inside strings will get percent-encoded, though).