examples package: Using the
- name a Gloop model property after a Java/Groovy keyword (e.g.
- have it contain special characters that are invalid in variable names in Java (e.g.
- change it to something else so that it matches the requirements of your API.
examples package demonstrates how the
Alias property works via the
service. When this service is executed, it will transform the input to XML, JSON, and YAML;
and then log the result to the console. The resulting XML, JSON, and YAML strings
will show the properties that have been renamed with their aliases.
Please see the following articles for more information:
1 2 3 4 5 6 7
PrintPerson.gloop service will provide an output similar to that shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
But what exactly are you looking at and what's so special about this service?
This example shows how you can serialize a JSON, XML, or YAML attribute/element/property to any name you like.
A Gloop model, when provided with an invalid property name, will attempt to make it a valid Gloop and
Groovy name. The desired name will be configured as the property's
Alias instead; and during serialization or
deserialization to JSON, XML or YAML, Gloop will use the
Person.model Gloop model contains invalid property names, each assigned an alias that are used
when it gets serialized. After serialization, instead of the Gloop-assigned property names, the value of the
Alias property will be used instead to write the output. When a property has an
Alias, it will appear in
curved brackets after the property itself in Gloop, as shown below:
Generate models from an existing source
You can generate Gloop models from an existing Gloop model, a JSON, XML or YAML string or file, or a JSON or XML schema.