Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geopjr/shipwreck
Automatically create Crystal JSON mappings from input
https://github.com/geopjr/shipwreck
crystal generator json svelte
Last synced: 15 days ago
JSON representation
Automatically create Crystal JSON mappings from input
- Host: GitHub
- URL: https://github.com/geopjr/shipwreck
- Owner: GeopJr
- Created: 2021-10-14T00:46:41.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-06T02:28:29.000Z (over 1 year ago)
- Last Synced: 2024-10-10T18:56:58.550Z (28 days ago)
- Topics: crystal, generator, json, svelte
- Language: JavaScript
- Homepage: https://shipwreck.geopjr.dev/
- Size: 771 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Shipwreck
Automatically create Crystal JSON mappings from input
#
#
## Use
- Go to https://shipwreck.geopjr.dev/
- Input your (complex or not) JSON in the textarea labeled as "Input"
- Copy the generated Crystal code from the textarea labeled as "Output"
- (Optional) Test the output on carc.in by clicking the button labelled as such#
## Warnings
- By clicking the button labelled as "Run on carc.in" you are sending the input to it. Please redact any sensitive information before doing so.
- JSONs with array as root won't work as it's outside the scope of this tool.
- Nothing is nullable by default.
- All Ints and Floats are 64 bit by default.
- Keys that are not valid Crystal variables (eg. starting with `-` or a number) will get assigned a random name.#
## Optimization
Optiomization recursively removes unnecessary structs untill there's nothing else to do. While this makes the output smaller, it also makes the structs unmaintainable.
Eg. The following JSON...
```json
{ "person": { "name": "Ciel", "height": 154.52 }, "cat": { "name": "Sakamoto", "height": 0.25 } }
```...would generate two structs, one for the `person` and one for the `cat`. But with optimization on, they will use the same struct since their keys & the types of their values are the same. But if the `person` gets a `weight` key but `cat` doesn't, a new struct just for the `person` needs to get generated. Having two seperate structs, in this case, would make adding a key easy.
While the above example uses a simple JSON, Shipwreck should be able to handle complex & nested objects (even if inside arrays!).
#
## Contributing
1. Read the [Code of Conduct](https://github.com/GeopJr/Shipwreck/blob/main/CODE_OF_CONDUCT.md)
2. Fork it ( https://github.com/GeopJr/Shipwreck/fork )
3. Create your feature branch (git checkout -b my-new-feature)
4. Commit your changes (git commit -am 'Add some feature')
5. Push to the branch (git push origin my-new-feature)
6. Create a new Pull Request