Parsing and creating JSON from Hyperlambda
This project provides JSON helper slots for Magic. More specifically, it provides the following slots.
- [json2lambda] - Creates a lambda object out of a JSON input string.
- [lambda2json] - Creates JSON out of a lambda object.
Usage
.json:@"{""property"": ""value""}"
json2lambda:x:-
lambda2json:x:-/*
The [lambda2json] slot can optionally take a [format] argument, with a boolean “true” value, which implies the resulting JSON will be indented and nicely formated, making it more readable.
Notice - Although all JSON can be transformed into lambda, the opposite is not necessarily true. This is because lambda allows for having multiple nodes with the same name for instance, which would result in a JSON object with multiple properties having the same key. Hence, have this in mind as you persist your lambda objects into JSON.
Project website
The source code for this repository can be found at github.com/polterguy/magic.lambda.json, and you can provide feedback, provide bug reports, etc at the same place.