https://github.com/molnarmark/jsontocr
🔮 JSON to Crystal JSON Mappings Converter
https://github.com/molnarmark/jsontocr
crystal crystal-lang crystal-language json types
Last synced: 9 months ago
JSON representation
🔮 JSON to Crystal JSON Mappings Converter
- Host: GitHub
- URL: https://github.com/molnarmark/jsontocr
- Owner: molnarmark
- Created: 2019-03-10T21:08:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-12T19:35:13.000Z (about 7 years ago)
- Last Synced: 2025-05-12T22:55:27.597Z (11 months ago)
- Topics: crystal, crystal-lang, crystal-language, json, types
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON To Crystal
Generate Crystal JSON mappings from JSON files. Outputs to STDOUT.
## Usage
```
npx jsontocr test.json > types.cr
```
## Examples
Take this JSON for example:
```json
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
```
Generated output will look like this:
```crystal
require "json"
class Root
JSON.mapping(
userId: {type: Float64, nilable: true},
id: {type: Float64, nilable: true},
title: {type: String, nilable: true},
body: {type: String, nilable: true},
)
end
```