Single-Element Arrays

You can specify that single items returned by a REST call be returned in an array.

The default behavior for REST calls is to return single items in a non-array. For example, if a single business service is returned by a REST call, the format is as follows:

"businessServices": {
    { "serviceName": "myService", "ServiceDetails": "myDetails" }
}

You can override this behavior so that the response is:

"businessServices": {
    [
       { "serviceName": "myService", "ServiceDetails": "myDetails" }
    ]
}

There are two places in which this behavior is specified:

  • RESTServiceConfig.properties file - This file contains the following property, which is set to false by default:

    enableSingleArrayElement=false

    When set to false, the single item is returned in a non-array. Set this property to true to cause single items returned by a REST call to always be returned in an array.

  • HTTP header - When making a REST call, you can include the Single-Element-Array HTTP header, and set it to true, to cause single items returned by that call to be in an array. If this header is included in the call, it overrides the setting of the enableSingleArrayElement property in the RESTServiceConfig.properties file.