Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gmlewis/json-to-moonbit

Translates JSON into MoonBit code in your browser instantly.
https://github.com/gmlewis/json-to-moonbit

code json moonbit

Last synced: 26 days ago
JSON representation

Translates JSON into MoonBit code in your browser instantly.

Awesome Lists containing this project

README

        

# gmlewis/json-to-moonbit

Translates JSON into MoonBit code. [Check it out!](http://gmlewis.github.io/json-to-moonbit)

This is based on Matt Holt's [json-to-go](http://mholt.github.io/json-to-go).

Things to note:

- The script sometimes has to make some assumptions, so give the output a once-over.
- In an array of objects, it is assumed that the first object is representative of the rest of them.
- The output is indented, but not formatted. Use `moon fmt`!

Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.

## Usage

- Read JSON file:

```sh
node json-to-moonbit.js sample.json
# or
bun json-to-moonbit.js sample.json
```

- Read JSON file from stdin:

```sh
node json-to-moonbit.js < sample.json
cat sample.json | node json-to-moonbit.js
# or
bun json-to-moonbit.js < sample.json
cat sample.json | bun json-to-moonbit.js
```

## Status

The code has been updated to support compiler:

```bash
$ moon version --all
moon 0.1.20240920 (13f54ef 2024-09-20) ~/.moon/bin/moon
moonc v0.1.20240920+a1bf2bf0d ~/.moon/bin/moonc
moonrun 0.1.20240920 (13f54ef 2024-09-20) ~/.moon/bin/moonrun
```

## Credits

JSON-to-Go is brought to you by Matt Holt ([mholt6](https://twitter.com/mholt6)).

JSON-to-MoonBit is brought to you by Glenn Lewis.

diff is Copyright (c) 2009-2015, Kevin Decker
All rights reserved.
and is used for testing. It is from: https://github.com/kpdecker/jsdiff/
with license: https://github.com/kpdecker/jsdiff/blob/master/LICENSE