WIP: jsonMessages: basic schema for JSON APIs #6
Loading…
Reference in New Issue
No description provided.
Delete Branch "ehmry/syndicate-protocols:json"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
JSON APIs are ubiquitous. This schema allows for reusuable connectors that translate Preserves to and from JSON endpoints.
This schema contradicts the current JSON schema described in the Preserves spec because it uses symbols for object keys rather than strings.
jsonMessages: basic schema for JSON APIsto WIP: jsonMessages: basic schema for JSON APIsMarking WIP because I haven't been able to regenerate the bundle.
Examples:
I'm open to a more descriptive record for encapsulating messages, like
<recv-json @data JSON>
.4e5e5947b9
to4a30cb442f
I like the idea of including JSON as a schema in syndicate-protocols (or perhaps even with preserves schema itself??) but I'm not sure about using
bool
for JSON booleans andsymbol
for JSON map keys, since preserves (de)serialization won't actually read/write JSON for those cases unless I'm misunderstanding something. Can you explain a bit more about your reasoning?tl;dr It's just easier to write things that operate over dictionaries that always have symbol keys
I'm proposing two different schema for JSON, one you get when parsing the syntax of JSON to Preserves, and the other when translating the semantics of JSON to Preserves. Shifting the semantic translation as close possible to things that only speak JSON avoids confusion and mistakes later.
In practice I do stuff with programs that speak JSON over Websockets or UNIX sockets, and what I receive I parse as JSON and then translate to Preserves, and then send the Preserves as binary to the Syndicate server as a message (and vice-versa). I try to move as much of my logic as practical into the server's scripting language because that maximizes re-use, and not having to think about what is and what isn't JSON makes it easier to do that. Writing a deeply nested dictionary pattern and then using a symbol key where you need a string key is going to break things in a way that is hard to find.
Also I think it's too much work to write a code generator that can emit native types for dictionaries with symbol keys as well as string keys.
I was planning on writing a blog post on what I'm doing with JSON sockets in the next few days, and that should make my justification more clear.
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Forgejo.