1String json = "{\"sectors\": [{\"times\":[{\"intensity\":30," +
2 "\"start\":{\"hour\":8,\"minute\":30},\"end\":{\"hour\":17,\"minute\":0}}," +
3 "{\"intensity\":10,\"start\":{\"hour\":17,\"minute\":5},\"end\":{\"hour\":23,\"minute\":55}}]," +
4 "\"id\":\"dbea21eb-57b5-44c9-a953-f61816fd5876\"}]}";
5 String result = JsonSchemaGenerator.outputAsString("Schedule", "this is a test", json);
6 /* sample output
7 {
8 "title": "Schedule",
9 "description": "this is a test",
10 "type": "object",
11 "properties": {
12 "sectors": {
13 "type": "array",
14 "items": {
15 "properties": {
16 "times": {
17 "type": "array",
18 "items": {
19 "properties": {
20 "intensity": {
21 "type": "number"
22 },
23 "start": {
24 "type": "object",
25 "properties": {
26 "hour": {
27 "type": "number"
28 },
29 "minute": {
30 "type": "number"
31 }
32 }
33 },
34 "end": {
35 "type": "object",
36 "properties": {
37 "hour": {
38 "type": "number"
39 },
40 "minute": {
41 "type": "number"
42 }
43 }
44 }
45 }
46 }
47 },
48 "id": {
49 "type": "string"
50 }
51 }
52 }
53 }
54 }
55 }
56 */
57
58 // To generate JSON schema into a file
59 JsonSchemaGenerator.outputAsFile("Schedule", "this is a test", json, "output-schema.json");
60
61 // To generate POJO(s)
62 JsonSchemaGenerator.outputAsPOJO("Schedule", "this is a test", json, "com.example", "generated-sources");
63 }
64