Join the DZone community and get the full member experience.
Join For Free
Get the Edge with a Professional Java IDE. 30-day free trial.
I'm happy to announce the very first release of my latest Erlang open source project,
jerg, a JSON Schema to Erlang Records Generator.
The objective of this project is to be a build tool that parses a rich domain model defined in JSON Schema (as specified in the
IETF Internet Draft
) in order to generate record definitions that can be used to Erlang applications to both read and write JSON.
I believe that having a formally defined object model for the data that's exchange over web resources is a major plus for APIs. It doesn't necessary imply that consumers have to generate static clients based on such a definition, but as far as the server is concerned, it raises the bar in term of consistency and opens the door for self-generated documentation.
doesn't deal with the actual mapping between JSON and records: there is already a library named
for that. It doesn't also deal with validation as, again, a library named
can take care of it.
This first version of
generates records with the appropriate type specification to enable type checking with
. It supports:
- cross-references for properties and collection items (ie the $ref property),
- default values,
- integer enumerations (other types can not be enumerated per limitation of the Erlang type specification).
It also supports a few extensions to JSON schema:
- extends: to allow a schema to extend another one in order to inherit all the properties of its parent (and any ancestors above it),
- abstract: to mark schemas that actually do not need to be output as records because they are just used through references and extension,
- recordName: to customize the name of the record generated from the concerned schema definition.
jerg has a few limitations, like its lack of support for embedded object schemas: pull-requests are more than welcome!
Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.
Published at DZone with permission
, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.