Specifies the way collections are serialized in Json format.
Sequence | Serializes as a plain sequence of collection elements. |
Wrapped | Includes the collection name item. This is the default value. |
Objects: Structured Data Type
Generators: .NET, .NET Framework, Java
Level: SDT level node
The Json Collection Serialization property is available in the SDT node that has been defined as a collection by selecting the Is Collection checkbox.
This property applies only at runtime.
Suppose you have defined an SDT called Countries, as shown in the image above.
Next, you define a Procedure object called CountryList as follows:
Variables:
Countries (Type:Countries)
country (Type:Countries.Country)
Rules:
Parm(out:&Countries);
Source:
&country = new()
&country.CountryName = "UY"
&Countries.Country.Add(&country)
&country = new()
&country.CountryName = "BR"
&Countries.Country.Add(&country)
Then in the Service Source of the API object, you define the following:
Countries{
[RestVerb(GET)]
ListCountries(out:&Countries) => ListCountries(&Countries);
}
When running by pressing F5, you will be able to display one of the following, depending on the value set in the Json Collection Serialization property:
Procedures as Rest Web Services in GeneXus
Data Providers as Rest Web Services in GeneXus