JSON and Sockets: Difference between revisions
No edit summary |
No edit summary |
||
| Line 23: | Line 23: | ||
RpcResult = RpcSuccess(JsonValue), RpcError(STRING) | RpcResult = RpcSuccess(JsonValue), RpcError(STRING) | ||
</pre> | </pre> | ||
[[File:prob_drone.jpeg||1000px]] | |||
Revision as of 07:17, 28 March 2025
ProB contains external functions to read and write JSON data and to communicate via sockets using JSON:
- LibraryJSON.def and LibraryJSON.mch providing the functions READ_JSON, READ_JSON_FROM_STRING, WRITE_JSON, WRITE_JSON_TO_STRING and the freetype JsonValue to read and write JSON data.
- LibraryZMQ_RPC.def and LibraryZMQ_RPC.mch: providing access to a JSON RPC (Remote Procedure Call) library either over regular sockets or ZMQ sockets.
LibraryJSON.mch defines a FREETYPE to represent JSON data in a type-safe way:
JsonValue = JsonNull,
JsonBoolean(BOOL),
JsonNumber(FLOAT),
JsonString(STRING),
JsonArray(seq(JsonValue)),
JsonObject(STRING +-> JsonValue)
Free Types are inductive data types. They are not standard B, but stem from Z and Rodin's theory plug-in.
LibraryZMQ_RPC.mch defines a FREETYPE to represent RPC in a type-safe way:
RpcResult = RpcSuccess(JsonValue), RpcError(STRING)
