void JsonSchema::readString(cJSON *childProperties, PropertiesPtr property) { cJSON *stringMax = cJSON_GetObjectItem(childProperties, "maxLength"); if (stringMax) { cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum"); if (exclusiveMax) { if (exclusiveMax->type == cJSON_True) property->setMax (--(stringMax->valueint)); else property->setMax(stringMax->valueint); } else property->setMax(stringMax->valueint); } cJSON *stringMin = cJSON_GetObjectItem(childProperties, "minLength"); if (stringMin) { cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum"); if (exclusiveMin) { if (exclusiveMin->type == cJSON_True) property->setMin( ++(stringMin->valueint)); else property->setMin(stringMin->valueint); } else property->setMin(stringMin->valueint); } cJSON *stringFormat = cJSON_GetObjectItem(childProperties, "format"); if (stringFormat) { property->setFormat(stringFormat->valuestring); } cJSON *stringPattern = cJSON_GetObjectItem(childProperties, "pattern"); if (stringPattern) { property->setPattern(stringPattern->valuestring); } }
void JsonSchema::readInteger(cJSON *childProperties, PropertiesPtr property) { cJSON *Max = cJSON_GetObjectItem(childProperties, "maximum"); if (Max) { cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum"); if (exclusiveMax) { if (exclusiveMax->type == cJSON_True) property->setMax( --(Max->valueint)); else property->setMax(Max->valueint); } else property->setMax(Max->valueint); } cJSON *Min = cJSON_GetObjectItem(childProperties, "minimum"); if (Min) { cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum"); if (exclusiveMin) { if (exclusiveMin->type == cJSON_True) property->setMin( ++(Min->valueint)); else property->setMin(Min->valueint); } else property->setMin(Min->valueint); } cJSON *multipleOf = cJSON_GetObjectItem(childProperties, "multipleOf"); if (multipleOf) { property->setMultipleOf(multipleOf->valueint); } }
void JsonSchema::readArray(cJSON *childProperties, PropertiesPtr property) { cJSON *itemValues = cJSON_GetObjectItem(childProperties, "items"); if (itemValues) { if (itemValues->type == 5) { int item_size = cJSON_GetArraySize(itemValues); int item_index = 0; do { cJSON *item = cJSON_GetArrayItem(itemValues, item_index); property->setItem(readItems(item)); } while ( ++item_index < item_size); } else { property->setItem(readItems(itemValues)); } } cJSON *itemsMax = cJSON_GetObjectItem(childProperties, "maxItems"); if (itemsMax) { cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum"); if (exclusiveMax) { if (exclusiveMax->type == cJSON_True) property->setMax( --(itemsMax->valueint)); else property->setMax(itemsMax->valueint); } else property->setMax(itemsMax->valueint); } cJSON *itemsMin = cJSON_GetObjectItem(childProperties, "minLength"); if (itemsMin) { cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum"); if (exclusiveMin) { if (exclusiveMin->type == cJSON_True) property->setMin( ++(itemsMin->valueint)); else property->setMin(itemsMin->valueint); } else property->setMin(itemsMin->valueint); } cJSON *uniqueItems = cJSON_GetObjectItem(childProperties, "uniqueItems"); if (uniqueItems) { property->setUnique(uniqueItems->type); } else { property->setUnique(cJSON_True); } cJSON *additionalItems = cJSON_GetObjectItem(childProperties, "additionalItems"); if (additionalItems) { property->setAdditionalItems(additionalItems->type); } else { property->setAdditionalItems(cJSON_True); } }