Skip to content

Commit 3c1f61d

Browse files
updated
1 parent 3d9f73c commit 3c1f61d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
Generates JSON Schema based from JSON data using JAVA
66

77
#### Motivation
8-
I have been googling a lot to find a library in JAVA that would generate me a JSON Schema based on the JSON data I have. But the library I found need to have a JAVA class in order to generate a JSON schema. So I made a simple JSON Schema Generator based on JSON data. If there is a library that already exists please let me know (via posting an Issue here) and I will be happy to use it in the current project I am working on. Thanks!
8+
I have been googling a lot to find a library in JAVA that would generate me a JSON Schema based on the JSON data I have. But most of the libraries I found need to have a JAVA class in order to generate a JSON schema. So I made a simple JSON Schema Generator based on JSON data. If there is a library that already exists please let me know (via posting an Issue here) and I will be happy to use it in the current project I am working on. Thanks!
99

1010
#### Usage
1111
Just call the static method JsonSchemaGenerator.outputAsString or JsonSchemaGenerator.outputAsFile
1212
```java
1313
public class GenerateSchema {
14-
public static void main(String[] args) throws IOException {
15-
String json = "{\"sectors\": [{\"times\":[{\"intensity\":30," +
16-
"\"start\":{\"hour\":8,\"minute\":30},\"end\":{\"hour\":17,\"minute\":0}}," +
17-
"{\"intensity\":10,\"start\":{\"hour\":17,\"minute\":5},\"end\":{\"hour\":23,\"minute\":55}}]," +
18-
"\"id\":\"dbea21eb-57b5-44c9-a953-f61816fd5876\"}]}";
19-
String result = JsonSchemaGenerator.outputAsString(json);
14+
public static void main(String[] args) throws IOException {
15+
String json = "{\"sectors\": [{\"times\":[{\"intensity\":30," +
16+
"\"start\":{\"hour\":8,\"minute\":30},\"end\":{\"hour\":17,\"minute\":0}}," +
17+
"{\"intensity\":10,\"start\":{\"hour\":17,\"minute\":5},\"end\":{\"hour\":23,\"minute\":55}}]," +
18+
"\"id\":\"dbea21eb-57b5-44c9-a953-f61816fd5876\"}]}";
19+
String result = JsonSchemaGenerator.outputAsString("Schedule", "this is a test", json);
2020
/* sample output
2121
{
2222
"title": "Schedule",
23-
"description": "Test",
23+
"description": "this is a test",
2424
"type": "object",
2525
"properties": {
2626
"sectors": {
@@ -68,11 +68,11 @@ public class GenerateSchema {
6868
}
6969
}
7070
*/
71-
72-
JsonSchemaGenerator.outputAsFile(json, "output-schema.json");
73-
// the above statement will generate the file on the directory
74-
// where code was executed
75-
}
71+
72+
JsonSchemaGenerator.outputAsFile(json, "output-schema.json");
73+
// the above statement will generate the file on the directory
74+
// where code was executed
75+
}
7676
}
7777
```
7878
#### Author

0 commit comments

Comments
 (0)