Output format: JSON
No additional settings.
Data Service REST jobs come with automatic serialization into data formats commonly used with REST services: JSON, XML and CSV. (To use a different format or override automatic serialization, see Custom Serialization.)
Records flowing through any edge connected to a port on the Output component in REST Job will be automatically serialized.
When a CSV serialization format is used, only one Output port can be connected, as all data must use the same metadata. If your graph logic has multiple edges, route all records into a single edge first before serialization, e.g. using the SimpleGather, Concatenate or Merge components.
Data Service automatically sets a Content-type response header based on a serialization format configured for the endpoint. The header is set to the following values:
application/json for JSON serialization;
application/xml for XML serialization;
text/csv for CSV serialization;
application/octet-stream for custom serialization (we recommend you override this).
JSON output format handles metadata with a single variant data field in a special way. When there is just one incoming edge with one field of type variant, its content is converted to JSON and sent as the response, ignoring the configuration options below. This makes it easy to build your response as a variant and send it to the output, or to modify the request payload. See the "Processing JSON payload" example in Data Service Examples on the Server.
In other cases, there are additional options available for JSON serialization. These are included to simplify response parsing on the consumer side for common JSON responses:
Possible JSON configurations are:
Settings | Example | Note |
---|---|---|
Output format: JSON No additional settings. |
|
Example assumes two incoming data records (shown in pipe-delimited format here): Title | Year Moby Dick | 1851 Don Quixote | 1605 Notice the top-level JSON object named books. The object name is identical to metadata on the output edge. Names of JSON attributes are derived from field names in record metadata. The array under the top-level object allows sending arbitrary number of records, while preserving valid JSON structure. |
Output format: JSON with Do not write metadata enabled. |
|
Omits the top-level JSON object. Useful when a service returns only one single type of record, i.e. when only a single Output port is connected. |
Output format: JSON. with Do not write metadata enabled, as well as Do not write top level array enabled. |
|
Skips the top level array. Returned JSON contains a single object with CloverDX record fields as attributes. Can be used only for a single record produced on a single port. Use this settings for services returning only a single record. If enabled and multiple records arrive on the output edge, the Data Service execution terminates with an exception. |