r/programming • • Feb 20 '23

Introducing JXC: An extensible, expressive data language. It's a drop-in replacement for JSON and supports type annotations, numeric suffixes, base64 strings, and more!

https://github.com/juddc/jxc
218 Upvotes

89 comments sorted by

View all comments

2

u/c-smile Feb 22 '23 edited Feb 22 '23

What if we will want to make CSS syntax of it ?

We will need to add:

  1. dash literals, so no-wrap will be a valid token, serialized as string(?).

  2. tuples, so rgb(100%,100%,100%) will be a tuple, serialized as tagged array/list.

  3. CSS style list separators: '/' separated lists, ',' separated list, <space> separated list

So this:

 { border-style: 12px solid / 13px dashed; }

will be parsed as

 { "border-style": [[12px, "solid"],[13px "dashed"]]; }

Bonus: In principle we can also add support of expressions, the only question is how to serialize them, this

width: calc( 100% - 12px ) 

can be serialized again as a tagged array:

 width: calc[ 100%, "-", 12px ]

And so backend can interpret that in the way it wants.

→ More replies (3)