Data-E in JSON
From Erights
(Difference between revisions)
(describe new 'atom' design) |
Kevin Reid (Talk | contribs) |
||
Line 1: | Line 1: | ||
- | + | There is interest (2009-01-07) in using [[CapTP]] in [[Cajita]] systems, with a [[JSON]] syntax for the message/serialization layer. Therefore, this page defines a JSON syntax for [[Data-E]]. | |
- | + | Except for literals, it is exactly the same as the [[Data-E in TermL]] format as implemented by [[deASTKit]]. | |
- | + | ==Literals== | |
- | + | String literals are copied as-is into JSON (rationale: compactness, readability). The three other types of literals are tagged, since JSON does not have character values and (we assume) JavaScript-based JSON implementations will not distinguish floats from integers. | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
{| | {| | ||
! !! Data-E Source !! JSON | ! !! Data-E Source !! JSON | ||
|- | |- | ||
- | | | + | | String || <code>"foo"</code> || <code>"foo"</code> |
|- | |- | ||
- | | | + | | Integer || <code>9</code> || <code>["int", 9]</code> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
|- | |- | ||
- | | | + | | Float64 || <code>9.99</code> || <code>["float64", 9.99]</code> |
|- | |- | ||
- | | | + | | Character || <code>'f'</code> || <code>["char", "f"]</code> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
|} | |} | ||
Line 68: | Line 46: | ||
| <code>def <var>t_9</var> := <var>...t_9...</var></code> || <code>["defrec", <var>9</var>, <var>...["ibid", 9]...</var>]</code> | | <code>def <var>t_9</var> := <var>...t_9...</var></code> || <code>["defrec", <var>9</var>, <var>...["ibid", 9]...</var>]</code> | ||
|} | |} | ||
- | |||
- | |||
- | |||
- | |||
[[Category:Data-E]] | [[Category:Data-E]] | ||
[[Category:JavaScript]] | [[Category:JavaScript]] |
Revision as of 02:01, 8 January 2009
There is interest (2009-01-07) in using CapTP in Cajita systems, with a JSON syntax for the message/serialization layer. Therefore, this page defines a JSON syntax for Data-E.
Except for literals, it is exactly the same as the Data-E in TermL format as implemented by deASTKit.
Contents |
Literals
String literals are copied as-is into JSON (rationale: compactness, readability). The three other types of literals are tagged, since JSON does not have character values and (we assume) JavaScript-based JSON implementations will not distinguish floats from integers.
Data-E Source | JSON | |
---|---|---|
String | "foo" | "foo"
|
Integer | 9 | ["int", 9]
|
Float64 | 9.99 | ["float64", 9.99]
|
Character | 'f' | ["char", "f"]
|
Import and ibid
Data-E Source | JSON |
---|---|
foo | ["import", "foo"]
|
t_9 | ["ibid", 9]
|
Call
Data-E Source | JSON |
---|---|
foo.bar(baz...) | ["call", foo, "bar", [baz...]]
|
Define
Data-E Source | JSON |
---|---|
def t_9 := bar | ["define", 9, bar]
|
def t_9 := ...t_9... | ["defrec", 9, ...["ibid", 9]...]
|