https://github.com/tomooda/jsonutil
JSON parser/printer for VDM-SL
https://github.com/tomooda/jsonutil
formal-methods formal-models formal-specification json vdm vdm-sl
Last synced: 3 months ago
JSON representation
JSON parser/printer for VDM-SL
- Host: GitHub
- URL: https://github.com/tomooda/jsonutil
- Owner: tomooda
- License: mit
- Created: 2013-12-18T23:53:57.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-25T00:10:47.000Z (over 11 years ago)
- Last Synced: 2025-01-18T01:44:21.280Z (4 months ago)
- Topics: formal-methods, formal-models, formal-specification, json, vdm, vdm-sl
- Size: 125 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
JSONUtil
========JSON parser/printer for VDM-SL
*CAUTION* : JSONUtil does NOT distinguish "" and [] because neither does VDM-SL.
## JSON <-> VDM mappings
JSON = seq of char;
STRING = seq of char;
ARRAY = seq of VALUE;
OBJECT = map STRING to VALUE;
NUMBER = real;
BOOL = bool;
VALUE = [ STRING | ARRAY | OBJECT | NUMBER | BOOL ];## exports the following functions
#### parseJSON : JSON -> bool * VALUE;
parses the given JSON string into a VDM value. This function permits extra data after a valid JSON portion.parseJSON("[1, true, \"string\", {\"key\":\"value\"}]")
==> mk_(true, [1, true, "string", {"key" |-> "value"}])parseJSON("[1, true, \"string\", {\"key\":\"value\"}] EXTRA")
==> mk_(true, [1, true, "string", {"key" |-> "value"}])#### strictParseJSON : JSON -> bool * VALUE;
parses the given JSON string into a VDM value. This function does NOT permit extra data after a valid JSON portion.strictParseJSON("[1, true, \"string\", {\"key\":\"value\"}]")
==> mk_(true, [1, true, "string", {"key" |-> "value"}])
strictParseJSON("[1, true, \"string\", {\"key\":\"value\"}] EXTRA")
==> mk_(false, nil)#### printJSON : VALUE -> JSON;
prints the VALUE values into JSON format.
printJSON([1, true, "string", {"key" |-> "value"}])
==> "[1, true, \"string\", {\"key\":\"value\"}]"