You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once you have instantiated the class, you can set restrictions on the size of the array via the 'set_min_size' and 'set_max_size' methods. The values that these functions receive as parameters are inclusive. To remove any restriction, you can use the 'remove_min_size' and 'remove_max_size' methods.
12
+
13
+
You can also determine what kind of elements can be part of this array via the 'set_element_property' method, which receives a JSONProperty object as a parameter. Otherwise, the array would accept any type of data. You can return to the default behavior using the 'remove_element_property'.
14
+
15
+
Finally, you can determine if you want each element of the array to be unique via the 'set_uniqueness' method and passing 'true' as its first parameter. When the array contains dictionaries, it would only check if the 'unique_key', the second parameter of this method, values of the dictionaries are equal. By default, the 'unique_key' string is empty. In this case, it would compare all the fields of the dictionaries.
16
+
17
+
## Example
18
+
19
+
In this example, the configuration structure has one required property. The property 'furniture' must be a list of 2 to 3 pieces of furniture. Each piece of furniture is an object with an 'id' that needs to be unique, and a 'name'.
20
+
21
+
```GDScript
22
+
# Create a JSON configuration file
23
+
var json_config_file = JSONConfigFile.new()
24
+
25
+
# Create a array property, which size must be between 2 to 3
"as_text": "The array contains two objects with the same 'id': [1] and [2], at 'furniture'.",
232
+
}
233
+
]
234
+
```
235
+
2
236
## Functions
3
237
4
238
The public methods of this class are:
@@ -13,4 +247,15 @@ The public methods of this class are:
13
247
|**remove_max_size**| None. | Removes any maximum size boundary. | Nothing. |
14
248
|**set_element_property**|**element_property -> JSONProperty:** <br> Object with the conditions that every element of the array must satisfy. | Sets the conditions that every element of the array must satisfy. | Nothing. |
15
249
|**remove_element_property**| None. | Allows the elements of the array to be anything. | Nothing. |
16
-
| **set_uniqueness** | **uniqueness -> bool:** <br> Determines if every object of the array must be different from each other. <br> **unique_key -> String (""):** <br> If the array has dictionaries as its elements, 'unique_key' determines which property to use when comparing if two of then are equal. <br><br> **WARNING:** An empty 'unique_key' means that every property of the dictionaries must be the same for them to be equal. | Determines if the elements of the array have to be unique. | Nothing.
250
+
| **set_uniqueness** | **uniqueness -> bool:** <br> Determines if every object of the array must be different from each other. <br> **unique_key -> String (""):** <br> If the array has dictionaries as its elements, 'unique_key' determines which property to use when comparing if two of then are equal. <br><br> **WARNING:** An empty 'unique_key' means that every property of the dictionaries must be the same for them to be equal. | Determines if the elements of the array have to be unique. | Nothing.
251
+
252
+
## Errors
253
+
254
+
This class could directly raise any of the following errors:
255
+
256
+
| Enum value | Description | Params | As text |
257
+
|-|-|-|-|
258
+
| WRONG_TYPE | The type of the input does not match the expected one. |**expected -> int:** <br> Takes the value [ARRAY](./ENUMS.md). | Wrong type: expected 'array' |
259
+
| ARRAY_SMALLER_THAN_MIN | The size of the input is smaller than the minimum. |**size -> int:** <br> The array size. <br> **min -> int:** <br> The minimum size allowed. | The array size ({size}) is smaller than the minimum allowed ({min}) |
260
+
| ARRAY_BIGGER_THAN_MAX | The size of the input is bigger than the maximum. |**size -> int:** <br> The array size. <br> **max -> int:** <br> The maximum size allowed. | The array size ({size}) is bigger than the maximum allowed ({max}) |
261
+
| ARRAY_TWO_ELEMENTS_ARE_EQUAL | Two elements of the array are equal. | **element_1 -> int:** <br> Index of the first element. <br> **element_2 -> int:** <br> Index of the second element. <br> **key -> String:** <br> The unique key <br><br> **WARNING:** The 'key' field only appears in the error dictionary if it has determined if two dictionaries are equal. | **Without 'key':** <br> The array contains two elements that are equal: \[{element_1}] and \[element_2] <br><br> **With 'key':** <br> The array contains two objects with the same '{key}': \[{element_1}] and \[element_2]
This JSON contains multiple errors in its 'person' property. It is missing the 'name' property, the 'age' value is not the correct type, and the structure does not specify its last property:
0 commit comments