Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danini-the-panini/json-lisp-js
Execute lisp-like s-expressions written in JSON (JavaScript Edition)
https://github.com/danini-the-panini/json-lisp-js
Last synced: 15 days ago
JSON representation
Execute lisp-like s-expressions written in JSON (JavaScript Edition)
- Host: GitHub
- URL: https://github.com/danini-the-panini/json-lisp-js
- Owner: danini-the-panini
- License: mit
- Created: 2018-02-17T10:12:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-17T12:06:18.000Z (almost 7 years ago)
- Last Synced: 2023-06-11T05:35:17.805Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON Lisp
Execute lisp-like s-expressions written in JSON.
The aim of JSON-Lisp is to allow for an executable code format that is simple and portable, as well as easy to parse and execute in a controlled, sandboxed environment. This allows it to be stored in a database, sent over an HTTP connection, collected from user input, and executed on either a client or a server's machine.
## Installation
Install with npm
$ npm install --save json-lisp
or yarn
$ yarn add json-lisp
## Usage
```javascript
const constants = {
"a": 5,
"b": 7,
"+": (a, b) => a + b,
"-": (a, b) => a - b
};const jsonLispEnv = new JSONLispEnv(constants);
jsonLispEnv.evaluate(["+", "a", "b"]) //=> 12
jsonLispEnv.evaluate(["-", "a", 3]) //=> 2
jsonLispEnv.evaluate(["+", 2, "b"]) //=> 9
jsonLispEnv.evaluate(["+", "a", ["-", "b", 2]]) //=> 10jsonLispEnv.evaluateJSON('["+", "a", ["-", "b", 2]]') //=> 10
```## See Also
1. [JSON::Lisp gem for Ruby](https://github.com/jellymann/json-lisp-ruby)
## Development
After checking out the repo, run `npm install` (or `yarn`) to install dependencies. Then, run `npm test` (or `yarn test`) to run the tests.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jellymann/json-lisp-js.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).