Generates a map through the fields and data of the struct.
1 struct.toMap
<struct.toMap>
<struct /> !
</struct.toMap>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Estruct | Struct | Struct to convert. |
Returns | |
---|---|
Type | Description |
Map | Returns a map with an element for each field of the struct. Each element of the map will have as key the field name and as value its content. |
Example
Conversion example of a struct to a map.
Copy
<xsql-script name='struct_set_sample1'> <body> <struct.declare type='sale'> <field name='number' type='integer' /> <field name='customer' type='string' /> <field name='amount' type='decimal' /> </struct.declare> <set name='m_sale'> <struct type='sale'> <number>1</number> <string>JOHN</string> <number>150.50</number> </struct> </set> <set name='map-sale'> <struct.toMap> <m_sale /> </struct.toMap> </set> <iterator name='m_field' type='key'> <in> <map-sale /> </in> <do> <println>FIELD: <m_field />, VALUE: <map.get name='map-sale'><m_field /></map.get></println> </do> </iterator> </body> </xsql-script>
Screen printing would be the following:
Copy
FIELD: amount, VALUE: 150.50 FIELD: number, VALUE: 1 FIELD: customer, VALUE: JOHN