Some applications specify their data properties in JavaScript Object Notation (JSON) format, which can be different from one use case to another, and so cannot be discovered by IBM App Connect. For example:

  • A document in an IBM Cloudant database might have data properties specified as the JSON:
      "Address": {
        "City": "London",
        "Number": 221,
        "Street": "Baker Street",
        "Zip": "NW1 5LA"
      "Birthdate": "1854-01-06",
      "Name": "Mr. Sherlock Holmes"
  • An HTTP method might have its request headers specified as the JSON:
    {"Accept": "application/json", "Content-Type": "application/json"}

In App Connect, you do not need to work with JSON to define the data properties for your own use case; you can use a simple property editor to specify the names and data types for your data properties, and then map to those properties as you would any other properties in App Connect.

Example 1: Using the property editor

Imagine you want to store a user’s details in a Cloudant database. The properties data structure might be something like the following:

  • Name (string)
  • Address
    • Number (number)
    • Name (string)
    • Street (string)
    • City (string)
    • Zip (string)
  • Birthdate (date)

When you create your flow in App Connect with an action such as Create Document, you see the document object with the option for you to add properties under the heading Document data, as shown in the following image:

(Click the image to view full size.)

To specify a property, you click Add property. As a result, a new property appears and you can set its name and data type. For the first property in the example above, you’d enter Name and leave the type as String.

To add the Address property, you click Add property again. This time enter the name Address, but change the type to Object. You should now see a second Add property option appear for the Address object. This allows you to define the properties within the Address object.

When you have added all the properties, you would have your document defined as follows:

(Click the image to view full size.)

You are now ready to use your document, just as if it had been defined as part of the action all along. Click Edit mappings to save your changes and show fields for the properties ready to be completed. You can map to these fields from source fields of nodes earlier in the flow, just as you would for other actions in App Connect. A completed mapping might look something like the following image:

(Click the image to view full size.)

If you want to change or delete properties, simply clicking Edit properties will switch back in to the property editor.

Note: You can only change a property if it does not have anything specified in its mapping field. So, before clicking Edit properties, ensure that the property’s field is empty.

In the property editor, properties with mappings are shown in grey and cannot be changed.

Example 2: Using the property editor to map a “source” array to a “target” array

In a second example of how the property editor works, let’s consider a property definition that enables you to map a “source” array from a previous node (for example, output from an event or a retrieve action) to a “target” array of a similar type. Start by defining properties for your target array. For example, add a property named Contacts with a data type of Array of objects. Then, add nested properties named Name and Email with a data type of String. (You want to define a Contacts mapping that is a list of objects with name and email details.)

Defining properties for an array of objects

You can then click Edit mappings to define mappings in the associated fields, which are initially shown as follows:

Initial fields for an array of objects

To complete these fields, first specify a mapping for a collection of objects in the Contacts parent field; for example, an Attendee [] array of objects that was returned by a previous retrieve action.

Mapping the parent field in an array of objects

Next, specify mappings for the child fields (Name and Email). For these entries, notice that there’s a Parent mapping item: Attendee section in the list of available inputs. Expand this section to make your selections.

Mapping the child fields in an array of objects

Here’s an example of the completed mappings:

Completed mappings for an array of objects

Specifying data properties as JSON

If you want, you can use JSON to define the data properties for your own use case. For example, to use JSON for a Cloudant document first ensure that there are no properties specified under “Document data”, and then click Edit mappings. This shows “Document data” as a JSON field; for example:

(Click the image to view full size.)

You can type or paste a JSON definition of your properties, and can map fields from earlier in the flow; for example:

(Click the image to view full size.)

Tip: If you want to switch from editing JSON to using the property editor, first empty the JSON field and then click Add property

Other use cases for defining your own data properties

There are other use cases for defining your own data properties. These include:

Join The Discussion

Your email address will not be published. Required fields are marked *