Esempio n. 1
0
 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);
     }
 }