Skip to content

Commit 8afde9c

Browse files
authored
Merge pull request #141 from ityuhui/yh-null-value-in-map-0909
Treat "null" as a valid value for a field of a JSON map
2 parents 2bb4393 + d305005 commit 8afde9c

32 files changed

+554
-378
lines changed

Diff for: kubernetes/model/v1_certificate_signing_request_spec.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,19 @@ v1_certificate_signing_request_spec_t *v1_certificate_signing_request_spec_parse
208208
cJSON *extra = cJSON_GetObjectItemCaseSensitive(v1_certificate_signing_request_specJSON, "extra");
209209
if (extra) {
210210
cJSON *extra_local_map = NULL;
211-
if(!cJSON_IsObject(extra)) {
211+
if(!cJSON_IsObject(extra) && !cJSON_IsNull(extra))
212+
{
212213
goto end;//primitive map container
213214
}
214-
extraList = list_createList();
215-
keyValuePair_t *localMapKeyPair;
216-
cJSON_ArrayForEach(extra_local_map, extra)
215+
if(cJSON_IsObject(extra))
217216
{
218-
cJSON *localMapObject = extra_local_map;
219-
list_addElement(extraList , localMapKeyPair);
217+
extraList = list_createList();
218+
keyValuePair_t *localMapKeyPair;
219+
cJSON_ArrayForEach(extra_local_map, extra)
220+
{
221+
cJSON *localMapObject = extra_local_map;
222+
list_addElement(extraList , localMapKeyPair);
223+
}
220224
}
221225
}
222226

Diff for: kubernetes/model/v1_config_map.c

+26-18
Original file line numberDiff line numberDiff line change
@@ -181,41 +181,49 @@ v1_config_map_t *v1_config_map_parseFromJSON(cJSON *v1_config_mapJSON){
181181
cJSON *binary_data = cJSON_GetObjectItemCaseSensitive(v1_config_mapJSON, "binaryData");
182182
if (binary_data) {
183183
cJSON *binary_data_local_map = NULL;
184-
if(!cJSON_IsObject(binary_data)) {
184+
if(!cJSON_IsObject(binary_data) && !cJSON_IsNull(binary_data))
185+
{
185186
goto end;//primitive map container
186187
}
187-
binary_dataList = list_createList();
188-
keyValuePair_t *localMapKeyPair;
189-
cJSON_ArrayForEach(binary_data_local_map, binary_data)
188+
if(cJSON_IsObject(binary_data))
190189
{
191-
cJSON *localMapObject = binary_data_local_map;
192-
if(!cJSON_IsString(localMapObject))
190+
binary_dataList = list_createList();
191+
keyValuePair_t *localMapKeyPair;
192+
cJSON_ArrayForEach(binary_data_local_map, binary_data)
193193
{
194-
goto end;
194+
cJSON *localMapObject = binary_data_local_map;
195+
if(!cJSON_IsString(localMapObject))
196+
{
197+
goto end;
198+
}
199+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
200+
list_addElement(binary_dataList , localMapKeyPair);
195201
}
196-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
197-
list_addElement(binary_dataList , localMapKeyPair);
198202
}
199203
}
200204

201205
// v1_config_map->data
202206
cJSON *data = cJSON_GetObjectItemCaseSensitive(v1_config_mapJSON, "data");
203207
if (data) {
204208
cJSON *data_local_map = NULL;
205-
if(!cJSON_IsObject(data)) {
209+
if(!cJSON_IsObject(data) && !cJSON_IsNull(data))
210+
{
206211
goto end;//primitive map container
207212
}
208-
dataList = list_createList();
209-
keyValuePair_t *localMapKeyPair;
210-
cJSON_ArrayForEach(data_local_map, data)
213+
if(cJSON_IsObject(data))
211214
{
212-
cJSON *localMapObject = data_local_map;
213-
if(!cJSON_IsString(localMapObject))
215+
dataList = list_createList();
216+
keyValuePair_t *localMapKeyPair;
217+
cJSON_ArrayForEach(data_local_map, data)
214218
{
215-
goto end;
219+
cJSON *localMapObject = data_local_map;
220+
if(!cJSON_IsString(localMapObject))
221+
{
222+
goto end;
223+
}
224+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
225+
list_addElement(dataList , localMapKeyPair);
216226
}
217-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
218-
list_addElement(dataList , localMapKeyPair);
219227
}
220228
}
221229

Diff for: kubernetes/model/v1_csi_persistent_volume_source.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,24 @@ v1_csi_persistent_volume_source_t *v1_csi_persistent_volume_source_parseFromJSON
273273
cJSON *volume_attributes = cJSON_GetObjectItemCaseSensitive(v1_csi_persistent_volume_sourceJSON, "volumeAttributes");
274274
if (volume_attributes) {
275275
cJSON *volume_attributes_local_map = NULL;
276-
if(!cJSON_IsObject(volume_attributes)) {
276+
if(!cJSON_IsObject(volume_attributes) && !cJSON_IsNull(volume_attributes))
277+
{
277278
goto end;//primitive map container
278279
}
279-
volume_attributesList = list_createList();
280-
keyValuePair_t *localMapKeyPair;
281-
cJSON_ArrayForEach(volume_attributes_local_map, volume_attributes)
280+
if(cJSON_IsObject(volume_attributes))
282281
{
283-
cJSON *localMapObject = volume_attributes_local_map;
284-
if(!cJSON_IsString(localMapObject))
282+
volume_attributesList = list_createList();
283+
keyValuePair_t *localMapKeyPair;
284+
cJSON_ArrayForEach(volume_attributes_local_map, volume_attributes)
285285
{
286-
goto end;
286+
cJSON *localMapObject = volume_attributes_local_map;
287+
if(!cJSON_IsString(localMapObject))
288+
{
289+
goto end;
290+
}
291+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
292+
list_addElement(volume_attributesList , localMapKeyPair);
287293
}
288-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
289-
list_addElement(volume_attributesList , localMapKeyPair);
290294
}
291295
}
292296

Diff for: kubernetes/model/v1_csi_volume_source.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,24 @@ v1_csi_volume_source_t *v1_csi_volume_source_parseFromJSON(cJSON *v1_csi_volume_
174174
cJSON *volume_attributes = cJSON_GetObjectItemCaseSensitive(v1_csi_volume_sourceJSON, "volumeAttributes");
175175
if (volume_attributes) {
176176
cJSON *volume_attributes_local_map = NULL;
177-
if(!cJSON_IsObject(volume_attributes)) {
177+
if(!cJSON_IsObject(volume_attributes) && !cJSON_IsNull(volume_attributes))
178+
{
178179
goto end;//primitive map container
179180
}
180-
volume_attributesList = list_createList();
181-
keyValuePair_t *localMapKeyPair;
182-
cJSON_ArrayForEach(volume_attributes_local_map, volume_attributes)
181+
if(cJSON_IsObject(volume_attributes))
183182
{
184-
cJSON *localMapObject = volume_attributes_local_map;
185-
if(!cJSON_IsString(localMapObject))
183+
volume_attributesList = list_createList();
184+
keyValuePair_t *localMapKeyPair;
185+
cJSON_ArrayForEach(volume_attributes_local_map, volume_attributes)
186186
{
187-
goto end;
187+
cJSON *localMapObject = volume_attributes_local_map;
188+
if(!cJSON_IsString(localMapObject))
189+
{
190+
goto end;
191+
}
192+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
193+
list_addElement(volume_attributesList , localMapKeyPair);
188194
}
189-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
190-
list_addElement(volume_attributesList , localMapKeyPair);
191195
}
192196
}
193197

Diff for: kubernetes/model/v1_endpoint.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,24 @@ v1_endpoint_t *v1_endpoint_parseFromJSON(cJSON *v1_endpointJSON){
243243
cJSON *deprecated_topology = cJSON_GetObjectItemCaseSensitive(v1_endpointJSON, "deprecatedTopology");
244244
if (deprecated_topology) {
245245
cJSON *deprecated_topology_local_map = NULL;
246-
if(!cJSON_IsObject(deprecated_topology)) {
246+
if(!cJSON_IsObject(deprecated_topology) && !cJSON_IsNull(deprecated_topology))
247+
{
247248
goto end;//primitive map container
248249
}
249-
deprecated_topologyList = list_createList();
250-
keyValuePair_t *localMapKeyPair;
251-
cJSON_ArrayForEach(deprecated_topology_local_map, deprecated_topology)
250+
if(cJSON_IsObject(deprecated_topology))
252251
{
253-
cJSON *localMapObject = deprecated_topology_local_map;
254-
if(!cJSON_IsString(localMapObject))
252+
deprecated_topologyList = list_createList();
253+
keyValuePair_t *localMapKeyPair;
254+
cJSON_ArrayForEach(deprecated_topology_local_map, deprecated_topology)
255255
{
256-
goto end;
256+
cJSON *localMapObject = deprecated_topology_local_map;
257+
if(!cJSON_IsString(localMapObject))
258+
{
259+
goto end;
260+
}
261+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
262+
list_addElement(deprecated_topologyList , localMapKeyPair);
257263
}
258-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
259-
list_addElement(deprecated_topologyList , localMapKeyPair);
260264
}
261265
}
262266

Diff for: kubernetes/model/v1_flex_persistent_volume_source.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,24 @@ v1_flex_persistent_volume_source_t *v1_flex_persistent_volume_source_parseFromJS
159159
cJSON *options = cJSON_GetObjectItemCaseSensitive(v1_flex_persistent_volume_sourceJSON, "options");
160160
if (options) {
161161
cJSON *options_local_map = NULL;
162-
if(!cJSON_IsObject(options)) {
162+
if(!cJSON_IsObject(options) && !cJSON_IsNull(options))
163+
{
163164
goto end;//primitive map container
164165
}
165-
optionsList = list_createList();
166-
keyValuePair_t *localMapKeyPair;
167-
cJSON_ArrayForEach(options_local_map, options)
166+
if(cJSON_IsObject(options))
168167
{
169-
cJSON *localMapObject = options_local_map;
170-
if(!cJSON_IsString(localMapObject))
168+
optionsList = list_createList();
169+
keyValuePair_t *localMapKeyPair;
170+
cJSON_ArrayForEach(options_local_map, options)
171171
{
172-
goto end;
172+
cJSON *localMapObject = options_local_map;
173+
if(!cJSON_IsString(localMapObject))
174+
{
175+
goto end;
176+
}
177+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
178+
list_addElement(optionsList , localMapKeyPair);
173179
}
174-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
175-
list_addElement(optionsList , localMapKeyPair);
176180
}
177181
}
178182

Diff for: kubernetes/model/v1_flex_volume_source.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,24 @@ v1_flex_volume_source_t *v1_flex_volume_source_parseFromJSON(cJSON *v1_flex_volu
159159
cJSON *options = cJSON_GetObjectItemCaseSensitive(v1_flex_volume_sourceJSON, "options");
160160
if (options) {
161161
cJSON *options_local_map = NULL;
162-
if(!cJSON_IsObject(options)) {
162+
if(!cJSON_IsObject(options) && !cJSON_IsNull(options))
163+
{
163164
goto end;//primitive map container
164165
}
165-
optionsList = list_createList();
166-
keyValuePair_t *localMapKeyPair;
167-
cJSON_ArrayForEach(options_local_map, options)
166+
if(cJSON_IsObject(options))
168167
{
169-
cJSON *localMapObject = options_local_map;
170-
if(!cJSON_IsString(localMapObject))
168+
optionsList = list_createList();
169+
keyValuePair_t *localMapKeyPair;
170+
cJSON_ArrayForEach(options_local_map, options)
171171
{
172-
goto end;
172+
cJSON *localMapObject = options_local_map;
173+
if(!cJSON_IsString(localMapObject))
174+
{
175+
goto end;
176+
}
177+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
178+
list_addElement(optionsList , localMapKeyPair);
173179
}
174-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
175-
list_addElement(optionsList , localMapKeyPair);
176180
}
177181
}
178182

Diff for: kubernetes/model/v1_json_schema_props.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -912,15 +912,19 @@ v1_json_schema_props_t *v1_json_schema_props_parseFromJSON(cJSON *v1_json_schema
912912
cJSON *dependencies = cJSON_GetObjectItemCaseSensitive(v1_json_schema_propsJSON, "dependencies");
913913
if (dependencies) {
914914
cJSON *dependencies_local_map = NULL;
915-
if(!cJSON_IsObject(dependencies)) {
915+
if(!cJSON_IsObject(dependencies) && !cJSON_IsNull(dependencies))
916+
{
916917
goto end;//primitive map container
917918
}
918-
dependenciesList = list_createList();
919-
keyValuePair_t *localMapKeyPair;
920-
cJSON_ArrayForEach(dependencies_local_map, dependencies)
919+
if(cJSON_IsObject(dependencies))
921920
{
922-
cJSON *localMapObject = dependencies_local_map;
923-
list_addElement(dependenciesList , localMapKeyPair);
921+
dependenciesList = list_createList();
922+
keyValuePair_t *localMapKeyPair;
923+
cJSON_ArrayForEach(dependencies_local_map, dependencies)
924+
{
925+
cJSON *localMapObject = dependencies_local_map;
926+
list_addElement(dependenciesList , localMapKeyPair);
927+
}
924928
}
925929
}
926930

Diff for: kubernetes/model/v1_label_selector.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,24 @@ v1_label_selector_t *v1_label_selector_parseFromJSON(cJSON *v1_label_selectorJSO
130130
cJSON *match_labels = cJSON_GetObjectItemCaseSensitive(v1_label_selectorJSON, "matchLabels");
131131
if (match_labels) {
132132
cJSON *match_labels_local_map = NULL;
133-
if(!cJSON_IsObject(match_labels)) {
133+
if(!cJSON_IsObject(match_labels) && !cJSON_IsNull(match_labels))
134+
{
134135
goto end;//primitive map container
135136
}
136-
match_labelsList = list_createList();
137-
keyValuePair_t *localMapKeyPair;
138-
cJSON_ArrayForEach(match_labels_local_map, match_labels)
137+
if(cJSON_IsObject(match_labels))
139138
{
140-
cJSON *localMapObject = match_labels_local_map;
141-
if(!cJSON_IsString(localMapObject))
139+
match_labelsList = list_createList();
140+
keyValuePair_t *localMapKeyPair;
141+
cJSON_ArrayForEach(match_labels_local_map, match_labels)
142142
{
143-
goto end;
143+
cJSON *localMapObject = match_labels_local_map;
144+
if(!cJSON_IsString(localMapObject))
145+
{
146+
goto end;
147+
}
148+
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
149+
list_addElement(match_labelsList , localMapKeyPair);
144150
}
145-
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
146-
list_addElement(match_labelsList , localMapKeyPair);
147151
}
148152
}
149153

0 commit comments

Comments
 (0)