Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
14test cases
16files differ
14modified
2new
0deleted
459changed lines
+426 −33insertions / deletions
Base 94fefaf04fde7b4f921703d52c0378783fa2c831 · PR merge d38cad65971cbcff8e1f9152ac936eb6255cc1f4 · Head 96c89b9211f8388ddd1c3aceadb1446cc91a2180 · raw patch
Test case

test/inputs/json/misc/26c9c.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -235,7 +235,7 @@ struct TopLevel {
235235 struct Meta * meta;
236236 };
237237
238-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
238+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
239239 struct Datum * cJSON_GetDatumValue(const cJSON * j);
240240 cJSON * cJSON_CreateDatum(const struct Datum * x);
241241 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/421d4.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -162,7 +162,7 @@ struct TopLevel {
162162 struct Meta * meta;
163163 };
164164
165-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
165+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
166166 struct Datum * cJSON_GetDatumValue(const cJSON * j);
167167 cJSON * cJSON_CreateDatum(const struct Datum * x);
168168 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/5f7fe.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -240,7 +240,7 @@ struct TopLevel {
240240 enum TypeName cJSON_GetTypeNameValue(const cJSON * j);
241241 cJSON * cJSON_CreateTypeName(const enum TypeName x);
242242
243-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
243+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
244244 struct Datum * cJSON_GetDatumValue(const cJSON * j);
245245 cJSON * cJSON_CreateDatum(const struct Datum * x);
246246 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/617e8.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -239,7 +239,7 @@ struct TopLevel {
239239 enum TypeName cJSON_GetTypeNameValue(const cJSON * j);
240240 cJSON * cJSON_CreateTypeName(const enum TypeName x);
241241
242-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
242+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
243243 struct Datum * cJSON_GetDatumValue(const cJSON * j);
244244 cJSON * cJSON_CreateDatum(const struct Datum * x);
245245 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/a0496.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -69,7 +69,7 @@ struct TopLevel {
6969 char * urlize_name;
7070 };
7171
72-#define cJSON_IsDatum(j) (cJSON_IsNumber(j) || cJSON_IsString(j))
72+#define cJSON_IsDatum(j) (cJSON_IsNumber(j) || cJSON_IsNull(j) || cJSON_IsString(j))
7373 struct Datum * cJSON_GetDatumValue(const cJSON * j);
7474 cJSON * cJSON_CreateDatum(const struct Datum * x);
7575 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/a3d8c.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -168,7 +168,7 @@ struct TopLevel {
168168 enum TypeName cJSON_GetTypeNameValue(const cJSON * j);
169169 cJSON * cJSON_CreateTypeName(const enum TypeName x);
170170
171-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
171+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
172172 struct Datum * cJSON_GetDatumValue(const cJSON * j);
173173 cJSON * cJSON_CreateDatum(const struct Datum * x);
174174 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/misc/fcca3.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -265,7 +265,7 @@ struct TopLevel {
265265 enum TypeName cJSON_GetTypeNameValue(const cJSON * j);
266266 cJSON * cJSON_CreateTypeName(const enum TypeName x);
267267
268-#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
268+#define cJSON_IsDatum(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
269269 struct Datum * cJSON_GetDatumValue(const cJSON * j);
270270 cJSON * cJSON_CreateDatum(const struct Datum * x);
271271 void cJSON_DeleteDatum(struct Datum * x);
Test case

test/inputs/json/priority/combinations4.json

2 generated files · +20 −20
Mcjsondefault / TopLevel.h+10 −10
@@ -841,7 +841,7 @@ struct PyodermiaElement * cJSON_GetPyodermiaElementValue(const cJSON * j);
841841 cJSON * cJSON_CreatePyodermiaElement(const struct PyodermiaElement * x);
842842 void cJSON_DeletePyodermiaElement(struct PyodermiaElement * x);
843843
844-#define cJSON_IsQuebrachineElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j))
844+#define cJSON_IsQuebrachineElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
845845 struct QuebrachineElement * cJSON_GetQuebrachineElementValue(const cJSON * j);
846846 cJSON * cJSON_CreateQuebrachineElement(const struct QuebrachineElement * x);
847847 void cJSON_DeleteQuebrachineElement(struct QuebrachineElement * x);
@@ -871,7 +871,7 @@ struct RewriteElement * cJSON_GetRewriteElementValue(const cJSON * j);
871871 cJSON * cJSON_CreateRewriteElement(const struct RewriteElement * x);
872872 void cJSON_DeleteRewriteElement(struct RewriteElement * x);
873873
874-#define cJSON_IsSaccoderm(j) (cJSON_IsArray(j) || cJSON_IsString(j))
874+#define cJSON_IsSaccoderm(j) (cJSON_IsArray(j) || cJSON_IsNull(j) || cJSON_IsString(j))
875875 struct Saccoderm * cJSON_GetSaccodermValue(const cJSON * j);
876876 cJSON * cJSON_CreateSaccoderm(const struct Saccoderm * x);
877877 void cJSON_DeleteSaccoderm(struct Saccoderm * x);
@@ -881,7 +881,7 @@ struct SantirElement * cJSON_GetSantirElementValue(const cJSON * j);
881881 cJSON * cJSON_CreateSantirElement(const struct SantirElement * x);
882882 void cJSON_DeleteSantirElement(struct SantirElement * x);
883883
884-#define cJSON_IsSaprophilous(j) (cJSON_IsObject(j) || cJSON_IsString(j))
884+#define cJSON_IsSaprophilous(j) (cJSON_IsObject(j) || cJSON_IsNull(j) || cJSON_IsString(j))
885885 struct Saprophilous * cJSON_GetSaprophilousValue(const cJSON * j);
886886 cJSON * cJSON_CreateSaprophilous(const struct Saprophilous * x);
887887 void cJSON_DeleteSaprophilous(struct Saprophilous * x);
@@ -891,12 +891,12 @@ struct SaxtenElement * cJSON_GetSaxtenElementValue(const cJSON * j);
891891 cJSON * cJSON_CreateSaxtenElement(const struct SaxtenElement * x);
892892 void cJSON_DeleteSaxtenElement(struct SaxtenElement * x);
893893
894-#define cJSON_IsScoffer(j) (cJSON_IsArray(j) || cJSON_IsObject(j))
894+#define cJSON_IsScoffer(j) (cJSON_IsArray(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
895895 struct Scoffer * cJSON_GetScofferValue(const cJSON * j);
896896 cJSON * cJSON_CreateScoffer(const struct Scoffer * x);
897897 void cJSON_DeleteScoffer(struct Scoffer * x);
898898
899-#define cJSON_IsScrampum(j) (cJSON_IsArray(j) || cJSON_IsBool(j))
899+#define cJSON_IsScrampum(j) (cJSON_IsArray(j) || cJSON_IsBool(j) || cJSON_IsNull(j))
900900 struct Scrampum * cJSON_GetScrampumValue(const cJSON * j);
901901 cJSON * cJSON_CreateScrampum(const struct Scrampum * x);
902902 void cJSON_DeleteScrampum(struct Scrampum * x);
@@ -941,7 +941,7 @@ struct Tabaxir * cJSON_GetTabaxirValue(const cJSON * j);
941941 cJSON * cJSON_CreateTabaxir(const struct Tabaxir * x);
942942 void cJSON_DeleteTabaxir(struct Tabaxir * x);
943943
944-#define cJSON_IsTalpiform(j) (cJSON_IsObject(j) || cJSON_IsNumber(j))
944+#define cJSON_IsTalpiform(j) (cJSON_IsObject(j) || cJSON_IsNumber(j) || cJSON_IsNull(j))
945945 struct Talpiform * cJSON_GetTalpiformValue(const cJSON * j);
946946 cJSON * cJSON_CreateTalpiform(const struct Talpiform * x);
947947 void cJSON_DeleteTalpiform(struct Talpiform * x);
@@ -976,7 +976,7 @@ struct Unerasing * cJSON_GetUnerasingValue(const cJSON * j);
976976 cJSON * cJSON_CreateUnerasing(const struct Unerasing * x);
977977 void cJSON_DeleteUnerasing(struct Unerasing * x);
978978
979-#define cJSON_IsUnguentarium(j) (cJSON_IsArray(j) || quicktype_cJSON_IsInteger(j))
979+#define cJSON_IsUnguentarium(j) (cJSON_IsArray(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j))
980980 struct Unguentarium * cJSON_GetUnguentariumValue(const cJSON * j);
981981 cJSON * cJSON_CreateUnguentarium(const struct Unguentarium * x);
982982 void cJSON_DeleteUnguentarium(struct Unguentarium * x);
@@ -986,12 +986,12 @@ struct UnimpeachablyElement * cJSON_GetUnimpeachablyElementValue(const cJSON * j
986986 cJSON * cJSON_CreateUnimpeachablyElement(const struct UnimpeachablyElement * x);
987987 void cJSON_DeleteUnimpeachablyElement(struct UnimpeachablyElement * x);
988988
989-#define cJSON_IsUnmortgaged(j) (cJSON_IsNumber(j) || cJSON_IsObject(j))
989+#define cJSON_IsUnmortgaged(j) (cJSON_IsNumber(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
990990 struct Unmortgaged * cJSON_GetUnmortgagedValue(const cJSON * j);
991991 cJSON * cJSON_CreateUnmortgaged(const struct Unmortgaged * x);
992992 void cJSON_DeleteUnmortgaged(struct Unmortgaged * x);
993993
994-#define cJSON_IsUnobstructed(j) (cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j))
994+#define cJSON_IsUnobstructed(j) (cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j))
995995 struct Unobstructed * cJSON_GetUnobstructedValue(const cJSON * j);
996996 cJSON * cJSON_CreateUnobstructed(const struct Unobstructed * x);
997997 void cJSON_DeleteUnobstructed(struct Unobstructed * x);
@@ -1021,7 +1021,7 @@ struct Unvarying * cJSON_GetUnvaryingValue(const cJSON * j);
10211021 cJSON * cJSON_CreateUnvarying(const struct Unvarying * x);
10221022 void cJSON_DeleteUnvarying(struct Unvarying * x);
10231023
1024-#define cJSON_IsVehemently(j) (cJSON_IsArray(j) || cJSON_IsBool(j))
1024+#define cJSON_IsVehemently(j) (cJSON_IsArray(j) || cJSON_IsBool(j) || cJSON_IsNull(j))
10251025 struct Vehemently * cJSON_GetVehementlyValue(const cJSON * j);
10261026 cJSON * cJSON_CreateVehemently(const struct Vehemently * x);
10271027 void cJSON_DeleteVehemently(struct Vehemently * x);
Mcjsonheader-only-false__source-style-single-source--491b617045b9 / TopLevel.h+10 −10
@@ -841,7 +841,7 @@ struct PyodermiaElement * cJSON_GetPyodermiaElementValue(const cJSON * j);
841841 cJSON * cJSON_CreatePyodermiaElement(const struct PyodermiaElement * x);
842842 void cJSON_DeletePyodermiaElement(struct PyodermiaElement * x);
843843
844-#define cJSON_IsQuebrachineElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j))
844+#define cJSON_IsQuebrachineElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
845845 struct QuebrachineElement * cJSON_GetQuebrachineElementValue(const cJSON * j);
846846 cJSON * cJSON_CreateQuebrachineElement(const struct QuebrachineElement * x);
847847 void cJSON_DeleteQuebrachineElement(struct QuebrachineElement * x);
@@ -871,7 +871,7 @@ struct RewriteElement * cJSON_GetRewriteElementValue(const cJSON * j);
871871 cJSON * cJSON_CreateRewriteElement(const struct RewriteElement * x);
872872 void cJSON_DeleteRewriteElement(struct RewriteElement * x);
873873
874-#define cJSON_IsSaccoderm(j) (cJSON_IsArray(j) || cJSON_IsString(j))
874+#define cJSON_IsSaccoderm(j) (cJSON_IsArray(j) || cJSON_IsNull(j) || cJSON_IsString(j))
875875 struct Saccoderm * cJSON_GetSaccodermValue(const cJSON * j);
876876 cJSON * cJSON_CreateSaccoderm(const struct Saccoderm * x);
877877 void cJSON_DeleteSaccoderm(struct Saccoderm * x);
@@ -881,7 +881,7 @@ struct SantirElement * cJSON_GetSantirElementValue(const cJSON * j);
881881 cJSON * cJSON_CreateSantirElement(const struct SantirElement * x);
882882 void cJSON_DeleteSantirElement(struct SantirElement * x);
883883
884-#define cJSON_IsSaprophilous(j) (cJSON_IsObject(j) || cJSON_IsString(j))
884+#define cJSON_IsSaprophilous(j) (cJSON_IsObject(j) || cJSON_IsNull(j) || cJSON_IsString(j))
885885 struct Saprophilous * cJSON_GetSaprophilousValue(const cJSON * j);
886886 cJSON * cJSON_CreateSaprophilous(const struct Saprophilous * x);
887887 void cJSON_DeleteSaprophilous(struct Saprophilous * x);
@@ -891,12 +891,12 @@ struct SaxtenElement * cJSON_GetSaxtenElementValue(const cJSON * j);
891891 cJSON * cJSON_CreateSaxtenElement(const struct SaxtenElement * x);
892892 void cJSON_DeleteSaxtenElement(struct SaxtenElement * x);
893893
894-#define cJSON_IsScoffer(j) (cJSON_IsArray(j) || cJSON_IsObject(j))
894+#define cJSON_IsScoffer(j) (cJSON_IsArray(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
895895 struct Scoffer * cJSON_GetScofferValue(const cJSON * j);
896896 cJSON * cJSON_CreateScoffer(const struct Scoffer * x);
897897 void cJSON_DeleteScoffer(struct Scoffer * x);
898898
899-#define cJSON_IsScrampum(j) (cJSON_IsArray(j) || cJSON_IsBool(j))
899+#define cJSON_IsScrampum(j) (cJSON_IsArray(j) || cJSON_IsBool(j) || cJSON_IsNull(j))
900900 struct Scrampum * cJSON_GetScrampumValue(const cJSON * j);
901901 cJSON * cJSON_CreateScrampum(const struct Scrampum * x);
902902 void cJSON_DeleteScrampum(struct Scrampum * x);
@@ -941,7 +941,7 @@ struct Tabaxir * cJSON_GetTabaxirValue(const cJSON * j);
941941 cJSON * cJSON_CreateTabaxir(const struct Tabaxir * x);
942942 void cJSON_DeleteTabaxir(struct Tabaxir * x);
943943
944-#define cJSON_IsTalpiform(j) (cJSON_IsObject(j) || cJSON_IsNumber(j))
944+#define cJSON_IsTalpiform(j) (cJSON_IsObject(j) || cJSON_IsNumber(j) || cJSON_IsNull(j))
945945 struct Talpiform * cJSON_GetTalpiformValue(const cJSON * j);
946946 cJSON * cJSON_CreateTalpiform(const struct Talpiform * x);
947947 void cJSON_DeleteTalpiform(struct Talpiform * x);
@@ -976,7 +976,7 @@ struct Unerasing * cJSON_GetUnerasingValue(const cJSON * j);
976976 cJSON * cJSON_CreateUnerasing(const struct Unerasing * x);
977977 void cJSON_DeleteUnerasing(struct Unerasing * x);
978978
979-#define cJSON_IsUnguentarium(j) (cJSON_IsArray(j) || quicktype_cJSON_IsInteger(j))
979+#define cJSON_IsUnguentarium(j) (cJSON_IsArray(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j))
980980 struct Unguentarium * cJSON_GetUnguentariumValue(const cJSON * j);
981981 cJSON * cJSON_CreateUnguentarium(const struct Unguentarium * x);
982982 void cJSON_DeleteUnguentarium(struct Unguentarium * x);
@@ -986,12 +986,12 @@ struct UnimpeachablyElement * cJSON_GetUnimpeachablyElementValue(const cJSON * j
986986 cJSON * cJSON_CreateUnimpeachablyElement(const struct UnimpeachablyElement * x);
987987 void cJSON_DeleteUnimpeachablyElement(struct UnimpeachablyElement * x);
988988
989-#define cJSON_IsUnmortgaged(j) (cJSON_IsNumber(j) || cJSON_IsObject(j))
989+#define cJSON_IsUnmortgaged(j) (cJSON_IsNumber(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
990990 struct Unmortgaged * cJSON_GetUnmortgagedValue(const cJSON * j);
991991 cJSON * cJSON_CreateUnmortgaged(const struct Unmortgaged * x);
992992 void cJSON_DeleteUnmortgaged(struct Unmortgaged * x);
993993
994-#define cJSON_IsUnobstructed(j) (cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j))
994+#define cJSON_IsUnobstructed(j) (cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j))
995995 struct Unobstructed * cJSON_GetUnobstructedValue(const cJSON * j);
996996 cJSON * cJSON_CreateUnobstructed(const struct Unobstructed * x);
997997 void cJSON_DeleteUnobstructed(struct Unobstructed * x);
@@ -1021,7 +1021,7 @@ struct Unvarying * cJSON_GetUnvaryingValue(const cJSON * j);
10211021 cJSON * cJSON_CreateUnvarying(const struct Unvarying * x);
10221022 void cJSON_DeleteUnvarying(struct Unvarying * x);
10231023
1024-#define cJSON_IsVehemently(j) (cJSON_IsArray(j) || cJSON_IsBool(j))
1024+#define cJSON_IsVehemently(j) (cJSON_IsArray(j) || cJSON_IsBool(j) || cJSON_IsNull(j))
10251025 struct Vehemently * cJSON_GetVehementlyValue(const cJSON * j);
10261026 cJSON * cJSON_CreateVehemently(const struct Vehemently * x);
10271027 void cJSON_DeleteVehemently(struct Vehemently * x);
Test case

test/inputs/json/priority/php-mixed-union.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -56,7 +56,7 @@ struct TopLevel {
5656 list_t * mixed;
5757 };
5858
59-#define cJSON_IsMixedElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
59+#define cJSON_IsMixedElement(j) (cJSON_IsBool(j) || cJSON_IsObject(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
6060 struct MixedElement * cJSON_GetMixedElementValue(const cJSON * j);
6161 cJSON * cJSON_CreateMixedElement(const struct MixedElement * x);
6262 void cJSON_DeleteMixedElement(struct MixedElement * x);
Test case

test/inputs/json/priority/unions.json

1 generated file · +1 −1
Mcjsondefault / TopLevel.h+1 −1
@@ -65,7 +65,7 @@ struct TopLevel {
6565 list_t * z;
6666 };
6767
68-#define cJSON_IsX(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsString(j))
68+#define cJSON_IsX(j) (quicktype_cJSON_IsInteger(j) || cJSON_IsNull(j) || cJSON_IsString(j))
6969 struct X * cJSON_GetXValue(const cJSON * j);
7070 cJSON * cJSON_CreateX(const struct X * x);
7171 void cJSON_DeleteX(struct X * x);
Test case

test/inputs/schema/direct-union.schema

2 generated files · +393 −0
Aschema-cjsondefault / TopLevel.c+310 −0
@@ -0,0 +1,310 @@
1+/**
2+ * TopLevel.c
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ */
5+
6+#include "TopLevel.h"
7+
8+struct Anything * cJSON_GetAnythingValue(const cJSON * j) {
9+ struct Anything * x = cJSON_malloc(sizeof(struct Anything));
10+ if (NULL != x) {
11+ memset(x, 0, sizeof(struct Anything));
12+ if (cJSON_IsNull(j)) {
13+ x->type = cJSON_NULL;
14+ }
15+ else if (cJSON_IsNumber(j)) {
16+ x->type = cJSON_Number;
17+ x->value.number = cJSON_GetNumberValue(j);
18+ }
19+ else if (quicktype_cJSON_IsInteger(j)) {
20+ x->type = cJSON_Integer;
21+ x->value.integer = cJSON_GetNumberValue(j);
22+ }
23+ else if (cJSON_IsBool(j)) {
24+ x->type = cJSON_Bool;
25+ x->value.boolean = cJSON_IsTrue(j);
26+ }
27+ else if (cJSON_IsString(j)) {
28+ x->type = cJSON_String;
29+ x->value.string = strdup(cJSON_GetStringValue(j));
30+ }
31+ else if (cJSON_IsArray(j)) {
32+ x->type = cJSON_Array;
33+ list_t * x1 = list_create(false, NULL);
34+ if (NULL != x1) {
35+ cJSON * e1 = NULL;
36+ cJSON_ArrayForEach(e1, j) {
37+ list_add_tail(x1, quicktype_cJSON_Duplicate(e1), sizeof(cJSON *));
38+ }
39+ x->value.anything_array = x1;
40+ }
41+ }
42+ else if (cJSON_IsObject(j)) {
43+ x->type = cJSON_Map;
44+ hashtable_t * x1 = hashtable_create(64, false);
45+ if (NULL != x1) {
46+ cJSON * e1 = NULL;
47+ cJSON_ArrayForEach(e1, j) {
48+ hashtable_add(x1, e1->string, quicktype_cJSON_Duplicate(e1), sizeof(cJSON *));
49+ }
50+ x->value.anything_map = x1;
51+ }
52+ }
53+ if (0 == x->type) { cJSON_free(x); return NULL; }
54+ }
55+ return x;
56+}
57+
58+cJSON * cJSON_CreateAnything(const struct Anything * x) {
59+ cJSON * j = NULL;
60+ if (NULL != x) {
61+ if (cJSON_NULL == x->type) {
62+ j = cJSON_CreateNull();
63+ }
64+ else if (cJSON_Number == x->type) {
65+ j = cJSON_CreateNumber(x->value.number);
66+ }
67+ else if (cJSON_Integer == x->type) {
68+ j = cJSON_CreateNumber(x->value.integer);
69+ }
70+ else if (cJSON_Bool == x->type) {
71+ j = cJSON_CreateBool(x->value.boolean);
72+ }
73+ else if (cJSON_String == x->type) {
74+ j = cJSON_CreateString(x->value.string);
75+ }
76+ else if (cJSON_Array == x->type) {
77+ cJSON * j1 = cJSON_CreateArray();
78+ if (NULL != j1) {
79+ cJSON * x1 = list_get_head(x->value.anything_array);
80+ while (NULL != x1) {
81+ cJSON_AddItemToArray(j1, quicktype_cJSON_Duplicate(x1));
82+ x1 = list_get_next(x->value.anything_array);
83+ }
84+ j = j1;
85+ }
86+ }
87+ else if (cJSON_Map == x->type) {
88+ cJSON * j1 = cJSON_CreateObject();
89+ if (NULL != j1) {
90+ char **keys1 = NULL;
91+ size_t count1 = hashtable_get_keys(x->value.anything_map, &keys1);
92+ if (NULL != keys1) {
93+ for (size_t index1 = 0; index1 < count1; index1++) {
94+ cJSON *x1 = hashtable_lookup(x->value.anything_map, keys1[index1]);
95+ cJSON_AddItemToObject(j1, keys1[index1], quicktype_cJSON_Duplicate(x1));
96+ }
97+ cJSON_free(keys1);
98+ }
99+ j = j1;
100+ }
101+ }
102+ }
103+ return j;
104+}
105+
106+void cJSON_DeleteAnything(struct Anything * x) {
107+ if (NULL != x) {
108+ if (cJSON_Number == x->type) {
109+ }
110+ else if (cJSON_Integer == x->type) {
111+ }
112+ else if (cJSON_Bool == x->type) {
113+ }
114+ else if (cJSON_String == x->type) {
115+ cJSON_free(x->value.string);
116+ }
117+ else if (cJSON_Array == x->type) {
118+ if (NULL != x->value.anything_array) {
119+ cJSON * x1 = list_get_head(x->value.anything_array);
120+ while (NULL != x1) {
121+ cJSON_Delete(x1);
122+ x1 = list_get_next(x->value.anything_array);
123+ }
124+ list_release(x->value.anything_array);
125+ }
126+ }
127+ else if (cJSON_Map == x->type) {
128+ if (NULL != x->value.anything_map) {
129+ char **keys1 = NULL;
130+ size_t count1 = hashtable_get_keys(x->value.anything_map, &keys1);
131+ if (NULL != keys1) {
132+ for (size_t index1 = 0; index1 < count1; index1++) {
133+ cJSON *x1 = hashtable_lookup(x->value.anything_map, keys1[index1]);
134+ if (NULL != x1) {
135+ cJSON_Delete(x1);
136+ }
137+ }
138+ cJSON_free(keys1);
139+ }
140+ hashtable_release(x->value.anything_map);
141+ }
142+ }
143+ cJSON_free(x);
144+ }
145+}
146+
147+struct Thing * cJSON_ParseThing(const char * s) {
148+ struct Thing * x = NULL;
149+ if (NULL != s) {
150+ cJSON * j = cJSON_Parse(s);
151+ if (NULL != j) {
152+ x = cJSON_GetThingValue(j);
153+ cJSON_Delete(j);
154+ }
155+ }
156+ return x;
157+}
158+
159+struct Thing * cJSON_GetThingValue(const cJSON * j) {
160+ struct Thing * x = NULL;
161+ if (NULL != j) {
162+ if (NULL != (x = cJSON_malloc(sizeof(struct Thing)))) {
163+ memset(x, 0, sizeof(struct Thing));
164+ if (cJSON_HasObjectItem(j, "optional")) {
165+ if (!cJSON_IsAnything(cJSON_GetObjectItemCaseSensitive(j, "optional"))) { cJSON_DeleteThing(x); return NULL; }
166+ x->optional = cJSON_GetAnythingValue(cJSON_GetObjectItemCaseSensitive(j, "optional"));
167+ if (NULL == x->optional) { cJSON_DeleteThing(x); return NULL; }
168+ }
169+ if (!cJSON_HasObjectItem(j, "required")) { cJSON_DeleteThing(x); return NULL; }
170+ if (cJSON_HasObjectItem(j, "required")) {
171+ if (!cJSON_IsAnything(cJSON_GetObjectItemCaseSensitive(j, "required"))) { cJSON_DeleteThing(x); return NULL; }
172+ x->required = cJSON_GetAnythingValue(cJSON_GetObjectItemCaseSensitive(j, "required"));
173+ if (NULL == x->required) { cJSON_DeleteThing(x); return NULL; }
174+ }
175+ }
176+ }
177+ return x;
178+}
179+
180+cJSON * cJSON_CreateThing(const struct Thing * x) {
181+ cJSON * j = NULL;
182+ if (NULL != x) {
183+ if (NULL != (j = cJSON_CreateObject())) {
184+ if (NULL != x->optional) {
185+ cJSON_AddItemToObject(j, "optional", cJSON_CreateAnything(x->optional));
186+ }
187+ cJSON_AddItemToObject(j, "required", cJSON_CreateAnything(x->required));
188+ }
189+ }
190+ return j;
191+}
192+
193+char * cJSON_PrintThing(const struct Thing * x) {
194+ char * s = NULL;
195+ if (NULL != x) {
196+ cJSON * j = cJSON_CreateThing(x);
197+ if (NULL != j) {
198+ s = cJSON_Print(j);
199+ cJSON_Delete(j);
200+ }
201+ }
202+ return s;
203+}
204+
205+void cJSON_DeleteThing(struct Thing * x) {
206+ if (NULL != x) {
207+ if (NULL != x->optional) {
208+ cJSON_DeleteAnything(x->optional);
209+ }
210+ if (NULL != x->required) {
211+ cJSON_DeleteAnything(x->required);
212+ }
213+ cJSON_free(x);
214+ }
215+}
216+
217+struct TopLevel * cJSON_ParseTopLevel(const char * s) {
218+ struct TopLevel * x = NULL;
219+ if (NULL != s) {
220+ cJSON * j = cJSON_Parse(s);
221+ if (NULL != j) {
222+ x = cJSON_GetTopLevelValue(j);
223+ cJSON_Delete(j);
224+ }
225+ }
226+ return x;
227+}
228+
229+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j) {
230+ struct TopLevel * x = NULL;
231+ if (NULL != j) {
232+ if (NULL != (x = cJSON_malloc(sizeof(struct TopLevel)))) {
233+ memset(x, 0, sizeof(struct TopLevel));
234+ if (!cJSON_HasObjectItem(j, "stuff")) { cJSON_DeleteTopLevel(x); return NULL; }
235+ if (cJSON_HasObjectItem(j, "stuff")) {
236+ if (!cJSON_IsObject(cJSON_GetObjectItemCaseSensitive(j, "stuff"))) { cJSON_DeleteTopLevel(x); return NULL; }
237+ hashtable_t * x1 = hashtable_create(64, false);
238+ if (NULL != x1) {
239+ cJSON * e1 = NULL;
240+ cJSON * j1 = cJSON_GetObjectItemCaseSensitive(j, "stuff");
241+ cJSON_ArrayForEach(e1, j1) {
242+ if (!cJSON_IsObject(e1)) { cJSON_DeleteTopLevel(x); return NULL; }
243+ hashtable_add(x1, e1->string, cJSON_GetThingValue(e1), sizeof(struct Thing *));
244+ }
245+ x->stuff = x1;
246+ }
247+ }
248+ else {
249+ x->stuff = hashtable_create(64, false);
250+ }
251+ }
252+ }
253+ return x;
254+}
255+
256+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x) {
257+ cJSON * j = NULL;
258+ if (NULL != x) {
259+ if (NULL != (j = cJSON_CreateObject())) {
260+ if (NULL != x->stuff) {
261+ cJSON * j1 = cJSON_CreateObject();
262+ if (NULL != j1) {
263+ char **keys1 = NULL;
264+ size_t count1 = hashtable_get_keys(x->stuff, &keys1);
265+ if (NULL != keys1) {
266+ for (size_t index1 = 0; index1 < count1; index1++) {
267+ struct Thing *x1 = hashtable_lookup(x->stuff, keys1[index1]);
268+ cJSON_AddItemToObject(j1, keys1[index1], cJSON_CreateThing(x1));
269+ }
270+ cJSON_free(keys1);
271+ }
272+ cJSON_AddItemToObject(j, "stuff", j1);
273+ }
274+ }
275+ }
276+ }
277+ return j;
278+}
279+
280+char * cJSON_PrintTopLevel(const struct TopLevel * x) {
281+ char * s = NULL;
282+ if (NULL != x) {
283+ cJSON * j = cJSON_CreateTopLevel(x);
284+ if (NULL != j) {
285+ s = cJSON_Print(j);
286+ cJSON_Delete(j);
287+ }
288+ }
289+ return s;
290+}
291+
292+void cJSON_DeleteTopLevel(struct TopLevel * x) {
293+ if (NULL != x) {
294+ if (NULL != x->stuff) {
295+ char **keys1 = NULL;
296+ size_t count1 = hashtable_get_keys(x->stuff, &keys1);
297+ if (NULL != keys1) {
298+ for (size_t index1 = 0; index1 < count1; index1++) {
299+ struct Thing *x1 = hashtable_lookup(x->stuff, keys1[index1]);
300+ if (NULL != x1) {
301+ cJSON_DeleteThing(x1);
302+ }
303+ }
304+ cJSON_free(keys1);
305+ }
306+ hashtable_release(x->stuff);
307+ }
308+ cJSON_free(x);
309+ }
310+}
Aschema-cjsondefault / TopLevel.h+83 −0
@@ -0,0 +1,83 @@
1+/**
2+ * TopLevel.h
3+ * This file has been autogenerated using quicktype https://github.com/quicktype/quicktype - DO NOT EDIT
4+ * This file depends of https://github.com/DaveGamble/cJSON, https://github.com/joelguittet/c-list and https://github.com/joelguittet/c-hashtable
5+ * To parse json data from json string use the following: struct <type> * data = cJSON_Parse<type>(<string>);
6+ * To get json data from cJSON object use the following: struct <type> * data = cJSON_Get<type>Value(<cjson>);
7+ * To get cJSON object from json data use the following: cJSON * cjson = cJSON_Create<type>(<data>);
8+ * To print json string from json data use the following: char * string = cJSON_Print<type>(<data>);
9+ * To delete json data use the following: cJSON_Delete<type>(<data>);
10+ */
11+
12+#ifndef __TOPLEVEL_H__
13+#define __TOPLEVEL_H__
14+
15+#ifdef __cplusplus
16+extern "C" {
17+#endif
18+
19+#include <stdint.h>
20+#include <stdbool.h>
21+#include <stdlib.h>
22+#include <string.h>
23+#include <regex.h>
24+#include <cJSON.h>
25+#include <hashtable.h>
26+#include <list.h>
27+
28+#define quicktype_cJSON_Duplicate(j) cJSON_Duplicate(j, true)
29+#define cJSON_Integer (1 << 18)
30+#define quicktype_cJSON_IsInteger(j) (cJSON_IsNumber(j) && (j)->valuedouble == (int64_t)(j)->valuedouble)
31+#ifndef cJSON_Bool
32+#define cJSON_Bool (cJSON_True | cJSON_False)
33+#endif
34+#ifndef cJSON_Map
35+#define cJSON_Map (1 << 16)
36+#endif
37+#ifndef cJSON_Enum
38+#define cJSON_Enum (1 << 17)
39+#endif
40+
41+struct Anything {
42+ int type;
43+ union {
44+ double number;
45+ int64_t integer;
46+ bool boolean;
47+ char * string;
48+ list_t * anything_array;
49+ hashtable_t * anything_map;
50+ } value;
51+};
52+
53+struct Thing {
54+ struct Anything * optional;
55+ struct Anything * required;
56+};
57+
58+struct TopLevel {
59+ hashtable_t * stuff;
60+};
61+
62+#define cJSON_IsAnything(j) (cJSON_IsNull(j) || cJSON_IsNumber(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsBool(j) || cJSON_IsString(j) || cJSON_IsArray(j) || cJSON_IsObject(j))
63+struct Anything * cJSON_GetAnythingValue(const cJSON * j);
64+cJSON * cJSON_CreateAnything(const struct Anything * x);
65+void cJSON_DeleteAnything(struct Anything * x);
66+
67+struct Thing * cJSON_ParseThing(const char * s);
68+struct Thing * cJSON_GetThingValue(const cJSON * j);
69+cJSON * cJSON_CreateThing(const struct Thing * x);
70+char * cJSON_PrintThing(const struct Thing * x);
71+void cJSON_DeleteThing(struct Thing * x);
72+
73+struct TopLevel * cJSON_ParseTopLevel(const char * s);
74+struct TopLevel * cJSON_GetTopLevelValue(const cJSON * j);
75+cJSON * cJSON_CreateTopLevel(const struct TopLevel * x);
76+char * cJSON_PrintTopLevel(const struct TopLevel * x);
77+void cJSON_DeleteTopLevel(struct TopLevel * x);
78+
79+#ifdef __cplusplus
80+}
81+#endif
82+
83+#endif /* __TOPLEVEL_H__ */
Test case

test/inputs/schema/rust-cycle-breaker-union.schema

1 generated file · +1 −1
Mschema-cjsondefault / TopLevel.h+1 −1
@@ -58,7 +58,7 @@ struct TopLevel {
5858 char * value;
5959 };
6060
61-#define cJSON_IsNext(j) (cJSON_IsObject(j) || cJSON_IsString(j))
61+#define cJSON_IsNext(j) (cJSON_IsObject(j) || cJSON_IsNull(j) || cJSON_IsString(j))
6262 struct Next * cJSON_GetNextValue(const cJSON * j);
6363 cJSON * cJSON_CreateNext(const struct Next * x);
6464 void cJSON_DeleteNext(struct Next * x);
Test case

test/inputs/schema/unevaluated-properties.schema

1 generated file · +1 −1
Mschema-cjsondefault / TopLevel.h+1 −1
@@ -68,7 +68,7 @@ struct TopLevel {
6868 struct Config * config;
6969 };
7070
71-#define cJSON_IsClosed(j) (cJSON_IsNumber(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsBool(j) || cJSON_IsString(j) || cJSON_IsArray(j) || cJSON_IsObject(j))
71+#define cJSON_IsClosed(j) (cJSON_IsNull(j) || cJSON_IsNumber(j) || quicktype_cJSON_IsInteger(j) || cJSON_IsBool(j) || cJSON_IsString(j) || cJSON_IsArray(j) || cJSON_IsObject(j))
7272 struct Closed * cJSON_GetClosedValue(const cJSON * j);
7373 cJSON * cJSON_CreateClosed(const struct Closed * x);
7474 void cJSON_DeleteClosed(struct Closed * x);
Test case

test/inputs/schema/vega-lite.schema

1 generated file · +2 −2
Mschema-cjsondefault / TopLevel.h+2 −2
@@ -6510,7 +6510,7 @@ struct Equal * cJSON_GetEqualValue(const cJSON * j);
65106510 cJSON * cJSON_CreateEqual(const struct Equal * x);
65116511 void cJSON_DeleteEqual(struct Equal * x);
65126512
6513-#define cJSON_IsRangeElement(j) (cJSON_IsNumber(j) || cJSON_IsObject(j))
6513+#define cJSON_IsRangeElement(j) (cJSON_IsNumber(j) || cJSON_IsObject(j) || cJSON_IsNull(j))
65146514 struct RangeElement * cJSON_GetRangeElementValue(const cJSON * j);
65156515 cJSON * cJSON_CreateRangeElement(const struct RangeElement * x);
65166516 void cJSON_DeleteRangeElement(struct RangeElement * x);
@@ -6560,7 +6560,7 @@ struct Scheme * cJSON_GetSchemeValue(const cJSON * j);
65606560 cJSON * cJSON_CreateScheme(const struct Scheme * x);
65616561 void cJSON_DeleteScheme(struct Scheme * x);
65626562
6563-#define cJSON_IsSortUnion(j) (cJSON_IsObject(j) || cJSON_IsString(j))
6563+#define cJSON_IsSortUnion(j) (cJSON_IsNull(j) || cJSON_IsObject(j) || cJSON_IsString(j))
65646564 struct SortUnion * cJSON_GetSortUnionValue(const cJSON * j);
65656565 cJSON * cJSON_CreateSortUnion(const struct SortUnion * x);
65666566 void cJSON_DeleteSortUnion(struct SortUnion * x);
No generated files match these filters.