██╗███████╗ ██████╗ ███╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗ ██████╗ ███████╗███╗ ██╗
██║██╔════╝██╔═══██╗████╗ ██║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝ ██╔════╝████╗ ██║
██║███████╗██║ ██║██╔██╗ ██║ ██║ ██║ ██║██║ ██║█████╗ ██║ ███╗█████╗ ██╔██╗ ██║
██ ██║╚════██║██║ ██║██║╚██╗██║ ██║ ██║ ██║██║ ██║██╔══╝ ██║ ██║██╔══╝ ██║╚██╗██║
╚█████╔╝███████║╚██████╔╝██║ ╚████║ ╚██████╗╚██████╔╝██████╔╝███████╗╚██████╔╝███████╗██║ ╚████║
╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝
---------------------------------------------------------------------------------------------------
A library for converting JSON into code for multiple programming languages. Made with ❤️ using 🦀
[![Crates.io](https://img.shields.io/crates/v/jsoncodegen.svg)](https://crates.io/crates/jsoncodegen)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
JSONCodeGen is a library designed to convert JSON into code for various programming languages, facilitating the creation of classes, structs, or equivalent data structures for serialization and deserialization.
## 🧑💻 Usage
add the library to your `Cargo.toml` file
```toml
jsoncodegen = "*"
```
extract schema and generate source code for any language
```rust
use jsoncodegen::{codegen, schema};
fn main() {
let json: serde_json::Value = serde_json::from_str(
r#"
{
"library": {
"name": "City Library",
"books": [
{
"title": "1984",
"author": "George Orwell",
"genres": ["Dystopian", "Political Fiction"]
},
{
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"genres": ["Classic", "Historical Fiction"]
}
]
}
}
"#,
).unwrap();
let schema = schema::extract(json);
let mut stdout = std::io::stdout().lock();
codegen::java(schema, &mut stdout).unwrap();
}
```
### Output
```java
// Books.java
import com.fasterxml.jackson.annotation.*;
public class Books {
private String author;
private List