Ordered Structures
This element assists in retaining the <structure> at the configured indices in a group of structures.
Possible Locations
The possible location of ordered-structures is a <property> with data type collections.
Child Elements
- Structure required recurrent
Samples
Simple
Let us say in the travelers resource, you created a <property> called traveler_name, in which you want,
0th index: title
1st index: first_name
2nd index: last_name
Following is a sample JSON body of the property and its values,
{
"travelers": [
{
"traveler_name": [
"Mr",
"John",
"Doe"
]
}
]
}
So, each key in the traveler_name should represent a string in a <structure>. It is not possible to use a <structure-group> as it would not maintain the order of the strings.
Now, use the ordered-structures as shown below to achieve this requirement.
<property name="traveler_name" type="collections">
<ordered-structures>
<structure>
<property type="string" values="Mr,Miss,Mrs">
<description> Provide any one of the titles from the possible values. </description>
</property>
</structure>
<structure>
<property type="string" regex="^[^\s]+$">
<description> Provide your first name without any space. </description>
</property>
</structure>
<structure>
<property type="string" length="1,-1">
<description> The last name should contain a minimum of one character. </description>
</property>
</structure>
</ordered-structures>
</property>
Here, the structures would not open to a default map property, as these child properties do not have a name attribute.
Complex
For the same use case of traveler_name as discussed above, the last_name can either denote a family name or an alias name of the traveler. For this requirement, the <structure> specified at the 2nd index should be removed and a new <structure-group> should be added under the property.
Following is the structure group that needs to be added under traveler_name,
<structure-group name="family/alias" type="one-of">
<structure name="family_name">
<property type="string">
<description> Provide your family name. </description>
</property>
</structure>
<structure name="alias">
<property type="string" regex="^alias ([a-zA-Z\s]+)$">
<description> Provide your nick name, if you have any. </description>
</property>
</structure>
</structure-group>
Here is the ordered-structures for this requirement,
<property name="traveler_name" type="collections">
<ordered-structures>
<structure>
<property type="string" values="Mr,Miss,Mrs">
<description> Provide any one of the titles from the possible values. </description>
</property>
</structure>
<structure>
<property type="string" regex="^[^\s]+$">
<description> Provide your first name without any space. </description>
</property>
</structure>
</ordered-structures>
<structure-group name="family/alias" type="one-of">
<structure name="family_name">
<property type="string">
<description> Provide your family name. </description>
</property>
</structure>
<structure name="alias">
<property type="string" regex="^alias ([a-zA-Z\s]+)$">
<description> Provide your nick name, if you have any. </description>
</property>
</structure>
</structure-group>
</property>
Last Updated 2025-05-30 16:54:59 +0530 IST
Yes
No
Send your feedback to us