Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathanstowe/json-infer
Infer the structure of a JSON object and make some Raku class to represent it
https://github.com/jonathanstowe/json-infer
json object raku serialization
Last synced: 2 months ago
JSON representation
Infer the structure of a JSON object and make some Raku class to represent it
- Host: GitHub
- URL: https://github.com/jonathanstowe/json-infer
- Owner: jonathanstowe
- License: other
- Created: 2015-08-30T18:06:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-03T13:07:51.000Z (over 1 year ago)
- Last Synced: 2023-07-03T15:04:28.448Z (over 1 year ago)
- Topics: json, object, raku, serialization
- Language: Raku
- Homepage:
- Size: 95.7 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# JSON::Infer
Create Raku classes to represent JSON data by some dodgy inference.
![Build Status](https://github.com/jonathanstowe/JSON-Infer/workflows/CI/badge.svg)
## Synopsis
Use the script to do it simply:
```
# Create the module in the directory "foo"raku-json-infer --uri=http://api.mixcloud.com/spartacus/party-time/ --out-dir=foo --class-name=Mixcloud::Show
```
Or do it in your own code:
```
use JSON::Infer;
my $obj = JSON::Infer.new();
my $ret = $obj.infer(uri => 'http://api.mixcloud.com/spartacus/party-time/', class-name => 'Mixcloud::Show');say $ret.make-class; # Print the class definition
```
## Description
JSON is nearly ubiquitous on the internet, developers love it for making
APIs. However the webservices that use it for transfer of data rarely
have a machine readable specification that can be turned into code so
developers who want to consume these services usually have to make the
client definition themselves.This module aims to provide a way to generate Raku classes that can represent
the data from a JSON source. The structure and the types of the data is
inferred from a single data item so the accuracy may depend on the
consistency of the data.## Installation
Assuming you have a working Rakudo installation you should be able to install this with *zef* :
# From the source directory
zef install .# Remote installation
zef install JSON::Infer
Other install mechanisms may be become available in the future.
## Support
Suggestions/patches are welcomed via github at https://github.com/jonathanstowe/JSON-Infer/issues
## Licence
This is free software.
Please see the [LICENCE](LICENCE) file in the distribution for details.
© Jonathan Stowe 2015, 2016, 2017, 2019, 2020, 2021