jenerator
Version, currently 1.0.13 versions
- 1.1.0latestAug 23, 2022
- 1.0.1not indexedAug 23, 2022
- 1.0.0not indexedAug 23, 2022
github.com/dscottboggs/jenerator
JSON Document ⇨ Crystal type definitions
7 stars
0 dependents
License: MIT
Nothing has been indexed for 1.0.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
jenerator:
github: dscottboggs/jenerator
version: ~> 1.0.1Then run:
shards installshard.yml
No shard.yml has been indexed for 1.0.1. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# Jenerator
### JSON Document ⇨ Crystal type definitions
Jump-start your next JSON API client by generating types from a sample API response!
The results this outputs are meant as a starting off point, to eliminate having
to write a lot of the boilerplate involved in creating a new project to parse
the response from an API, without resorting to the runtime overhead of relying
on `JSON.parse`. You will probably want to review the generated code and make
some revisions, especially if your data sample includes arrays of objects (see
Known Issues).
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
jenerator:
github: dscottboggs/jenerator
```
2. Run `shards install`
## Usage
```crystal
require "jenerator"
sample = %[{"data": "just some text", "listOfData": ["one", 2, 3.0]}]
puts Jenerator.process sample
```
The above code sample would output this Crystal code:
```crystal
require "json"
class Document
include JSON::Serializable
@data : String
@[JSON::Field(key: "listOfData")]
@list_of_data : Array(String | Int64 | Float64)
end
```
There's also a compiled script which you can download as a static binary from
the ["releases"](https://github.com/dscottboggs/cached-file-server/releases)
page which will generate new Crystal source files for each `.json` file in a
directory.
# Known issues:
When generating code for an array of objects, a new class or struct is
generated for each object member of that array. The resulting type
eliminates redundant types from the union, but the types are still declared.
See [jenerator_spec.cr](./spec/jenerator_spec.cr) for an example.
## Contributing
1. Fork it (<https://github.com/dscottboggs/jenerator/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [D. Scott Boggs](https://github.com/dscottboggs) - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.0.1- Tagged
- Aug 23, 2022
- Commit
5a0c4d79d509- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/dscottboggs/jenerator
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 3