Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bonitoflakez/gojson2class
a utility that converts JSON schema to classes
https://github.com/bonitoflakez/gojson2class
c cpp golang java json json-schema jsonschema rust typescript
Last synced: 2 months ago
JSON representation
a utility that converts JSON schema to classes
- Host: GitHub
- URL: https://github.com/bonitoflakez/gojson2class
- Owner: bonitoflakez
- License: gpl-3.0
- Created: 2023-05-21T17:48:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-12T19:01:06.000Z (about 1 year ago)
- Last Synced: 2024-11-28T12:53:14.457Z (2 months ago)
- Topics: c, cpp, golang, java, json, json-schema, jsonschema, rust, typescript
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goJSON2CLASS
`goJSON2CLASS` is a utility that converts JSON schema to classes
## Usage
```txt
Usage: goJSON2CLASS -l -s -o-l >> choose a language.
Example: `-l rust` (default: nil)-s >> path to file containing JSON schema. (default: schema.json)
Example: `-s schema.json`-o >> path to output file with extension. (default: output.txt)
Example: `-o output.rs`-p >> define public if supported by language (default: false)
Example: `-p`
```## Supported Inputs
goJSON2CLASS only supports JSON Schema
## Supported Languages
C, Go, C++, Java, Rust, TypeScript
_If your favorite language is missing- please generate an issue or implement it by yourself._
---
### [Installation](./docs/INSTALLATION.md)
---
### Usage Example
#### Sample Schema
```json
{
"title": "Root",
"properties": {
"property1": {
"type": "string"
},
"property2": {
"type": "integer"
},
"property3": {
"type": "object",
"title": "Property3",
"properties": {
"nestedProperty1": {
"type": "boolean"
},
"nestedProperty2": {
"type": "array",
"items": {
"type": "string"
}
},
"nestedProperty3": {
"type": "string"
}
}
}
}
}
```#### Generating C Code
```txt
>> goJSON2CLASS -l c -s schema.json -o output.c
Done!
```Output
```c
#include
#include
#include#define PROPERTY3_NESTEDPROPERTY2_SIZE 50
typedef struct Root Root;
typedef struct Property3 Property3;struct Property3 {
bool nestedProperty1;
char* nestedProperty2[PROPERTY3_NESTEDPROPERTY2_SIZE];
char* nestedProperty3;
};
struct Root {
char* property1;
int property2;
Property3 property3;
};
```---
### [Examples](./docs/Example.md)
---
### LICENSE
[GPL](./LICENSE)