From 6358a44097a1dc0066bb0e04f0589a2769668344 Mon Sep 17 00:00:00 2001 From: rahulgs12 Date: Thu, 4 May 2023 14:54:25 -0400 Subject: [PATCH] add example --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b02a0fc..d995cb1 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,47 @@ generated_data = jsonformer() print(generated_data) ``` +### Jsonformer works on complex schemas, even with tiny models. Here is an example of a schema with nested objects and arrays, generated by a 3B parameter model. + +```python +{"type": "object", "properties": {"car": {"type": "object", "properties": {"make": {"type": "string"}, "model": {"type": "string"}, "year": {"type": "number"}, "colors": {"type": "array", "items": {"type": "string"}}, "features": {"type": "object", "properties": {"audio": {"type": "object", "properties": {"brand": {"type": "string"}, "speakers": {"type": "number"}, "hasBluetooth": {"type": "boolean"}}}, "safety": {"type": "object", "properties": {"airbags": {"type": "number"}, "parkingSensors": {"type": "boolean"}, "laneAssist": {"type": "boolean"}}}, "performance": {"type": "object", "properties": {"engine": {"type": "string"}, "horsepower": {"type": "number"}, "topSpeed": {"type": "number"}}}}}}}, "owner": {"type": "object", "properties": {"firstName": {"type": "string"}, "lastName": {"type": "string"}, "age": {"type": "number"}}}}} +``` + +```python +{ + car: { + make: "audi", + model: "model A8", + year: 2016.0, + colors: [ + "blue" + ], + features: { + audio: { + brand: "sony", + speakers: 2.0, + hasBluetooth: True + }, + safety: { + airbags: 2.0, + parkingSensors: True, + laneAssist: True + }, + performance: { + engine: "4.0", + horsepower: 220.0, + topSpeed: 220.0 + } + } + }, + owner: { + firstName: "John", + lastName: "Doe", + age: 40.0 + } +} +``` + ## Features - Bulletproof JSON generation: Jsonformer ensures that the generated JSON is always syntactically correct and conforms to the specified schema. @@ -67,8 +108,6 @@ pip install jsonformer ## Development - - [Poetry](https://python-poetry.org/docs/#installation) is used for dependency management. ```bash