Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexkorban/json-to-elm
A package to help generate Elm JSON decoders and encoders from a JSON sample
https://github.com/alexkorban/json-to-elm
Last synced: 6 days ago
JSON representation
A package to help generate Elm JSON decoders and encoders from a JSON sample
- Host: GitHub
- URL: https://github.com/alexkorban/json-to-elm
- Owner: alexkorban
- License: agpl-3.0
- Created: 2021-10-29T23:14:54.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-07T19:11:23.000Z (about 3 years ago)
- Last Synced: 2024-05-01T20:45:27.121Z (6 months ago)
- Language: Elm
- Size: 48.8 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This package helps generate Elm JSON decoders and encoders from a JSON sample.
I only published it because I needed to share the code between my projects, hence
the lacklustre documentation. I don't currently intend to produce a generally useful package.The package provides a single function, `fromJsonSample`, which generates Elm code defining
imports, types, decoders, and encoders from a supplied JSON sample:```
ElmCodeGenerator.fromJsonSample
{ rootTypeName = topLevelTypeName
, decodeImport = { importAlias = "Json.Decode", exposingSpec = ElmCodeGenerator.ExposingNone }
, encodeImport = { importAlias = "Json.Encode", exposingSpec = ElmCodeGenerator.ExposingNone }
, decoderStyle = ElmCodeGenerator.PlainDecoders
, namingStyle = ElmCodeGenerator.NounNaming
}
"""{"a": 1, "b": "str"}"""
```