Casting with JSON schema types

In a message map, you can use the cast function to define wildcards to a JSON data type, or extend a JSON type that is defined with the "oneOf" or "anyOf" keywords.

Before you begin

About this task

You can use a mapping cast with JSON schema types when you want to use wildcards or combine complex JSON schema; for example:
  • When your message model includes a wildcard. A wildcard is an element in your schema that is defined as xsd:any or xsd:anyType. The model for the Message Assembly Environment and Local Environment folders include wildcards (under the Variables folder, for example), which allow you to define data specifically for the operation of your flow.
  • When a JSON schema includes the "oneOf" or "anyOf" keywords, to allow the flexibility to extend the content of a data type.

Procedure

To cast a wildcard or a JSON schema type that includes the "oneOf" or "anyOf" keyword, complete the following steps:

  1. Select the wildcard or JSON schema type that you want to use.
  2. Right-click the wildcard or JSON schema type, and then select Cast.
  3. In the Type Selection window, choose the required type, and then select OK.

    The options depend on the JSON schema files that are available in the same project container as the message map and the item that is being cast.

    The following figure shows the Type Selection window that you might see when casting the environment tree Variables in a project container that contains a REST Swagger document used by a RESTRequest node:

    This figure shows the Type Selection window that opens when you select Cast....

    The following figure shows the Type Selection window that you might see when casting a JSON type Contact that is defined using the JSON keyword "oneOf", which extends the type as either an address or telephone contact:

    This figure shows the Type Selection window that you might see when casting a JSON type Contact that is defined using the JSON keyword "oneOf".

    For example:
    "Contact" : {
         "properties": {
                 "conType": {
                        "type": "string"
                 }
          	},
            "oneOf": [
    {"type": "null"},
    {"$ref":"#/definitions/Address"},
    {"$ref":"#/definitions/TelContacts"}
                     ]
    }

Results

The message map contains a choice of cast items group, including the type that you have picked for the cast action; you can now complete mappings to the data members of that type. For example:This figure shows how to map to data members of the type selected from the cast action.

What to do next

Define additional transformations between elements in the message map. For more information, see Transform types in the Graphical Data Mapping editor.