Skip to main content

xSuite Interface Windows Prism 5.x – Online Help

Output Format "Json"

This output format generates a JSON file from the index data of the document. The file attachments of the document can be embedded, or references to file attachments to be carried externally can be generated.

Notice

Here, define the properties for the output values to be created in the JSON file in a proprietary syntax (see XPath Syntax). This syntax is based on the JSONPath syntax (see JSON index data reader), so this is what it is called below. Functionally, however, this syntax only has to do with JSON output format creation here, while JSONPath is actually a syntax for reading in existing JSON data.

Property

Description

OutputFormat[].AttachFileMode

Mode determining how additional file attachments are added to the JSON file:

  • None: no attachments (default value)

  • Reference: as a file reference in the JSON file

  • Embedded: BASE64-coded binary data, embedded in the JSON file

The physical availability of the files in the file system that are referenced in the Reference mode is not part of this output format creation. They must be made available differently (e.g., via a file-based output system such as "File") (see also comparable example for the"InternalJson" output format).

OutputFormat[].ItemProperty[](*)

Subparameters for defining a JSON property for receiving tabular data

If item data or other table data is output, configuration of this property is mandatory. The property must represent a JSON element of type "Array."

  1. ItemProp*: related property in JSONPath syntax

  2. FieldName: table name of the source fields in the field catalog (optional)

The .ItemProperty[] property can be defined multiple times with different FieldName parameters if there are multiple JSON elements with table data to which values from different source tables are assigned. If the parameter is omitted, the entry will apply globally to all tables.

In field mapping under .OutputName, specify the path to the target property to be generated. For tabular data, define this path relative to the property specified in the ItemProp parameter. For each table row, a child object is implicitly generated as an array element. In turn, the path specified in .OutputName is created in this subobject. If .OutputName is empty, the output value is written directly to the target array as an elementary value. However, this is only applicable to table data that includes only one column.

OutputFormat[].AttachFileProperty(*)

Definition of a JSON property in JSONPath syntax under which the reference to file attachments or the binary data of file attachments are output

This definition is required in the Reference and Embedded modes.

  1. File*: full path to the (parent) property for the reference/binary data output

  2. Data: relative path for the reference/binary data (optional)

  3. Name: path for the additional output of the file name (optional)

  4. Type: path for the additional output of the MIME type (optional)

To output multiple file attachments, the path defined in the File parameter must represent a JSON element of type "Array." Only relative paths to it must be specified in the Data, Name, and Type parameters. A child object is then implicitly generated as an array element for each attachment; in turn, the path specified in Data, Name, and Type is created in it. If Data is empty, the output value will be written directly to the target array as an elementary value. Name and Type will be ignored.

To output a single file attachment, an elementary property can be defined in File instead of an array. This then serves directly as the target property for the reference or binary data, so that the Data parameter has no relevance. If Name and Type are also output, then, in this case, they must contain absolute path specifications.

OutputFormat[].AttachFileRefMacro

Macro expression for formatting the file reference value in Reference mode (optional)

The default value is preset with the expression "%FileName%" (i.e., only the pure file name will be output).

XPath Syntax

The properties of this output format use a restricted variant of the JSONPath syntax. This syntax consists of a path specification composed of the dot-separated property names of nested objects. The lowest property in the path takes the elementary target value. By default, the parent properties each represent an object.

If a property is to represent an array, indicate this with square brackets after the property name. For instance, you would need to do this for the properties .ItemProperty[] and .AttachFileProperty (i.e., for table rows and file attachments).

Other values can also be output to an array if required. In this case, specify the array element. A numeric value in the square brackets specifies a concrete element number, with counting starting at 1. A search key {name}={value} defines a search for an array element of the type "object" that contains a property with the specified name and value. Array elements that do not yet exist are automatically created, with the property for the search key also being set if necessary. Only the string type is supported as its value. If neither element number nor search key is specified, the first array element is always referenced and only created if the array is still empty.

The following examples show which JSON elements result, based on different JSONPath expressions:

Proprietary JSONPath expression

Generated JSON fragment

Doc.InvoiceNumber

Doc.InvoiceDate

{
   "Doc": {
      "InvoiceNumber": …,
      "InvoiceDate": …
   }
}

Fields[1]

Fields[2]

{
   "Fields": [
      …,
      …
   ]
}

Fields[1].Value

Fields[2].Value

{
   "Fields": [
      {
         "Value": …
      },{
         "Value": …
      }
   ]
}

Fields[Name=InvoiceNumber].Value

Fields[Name=InvoiceDate].Value

{
   "Fields": [
      {
         "Name": "InvoiceNumber",
         "Value": …
      },{
         "Name": "InvoiceDate",
         "Value": …
      }
   ]
}

The following excerpt illustrates the use of JSONPath syntax in the context of practical output format configuration:

{
   "OutputFormat": [
      {
         "ItemProperty": [
            "ItemProp: Document.Items[]"
         ],
         "AttachFileProperty": "File: Document.Files[], Data: Reference, Name: Name"
         "Field": [
            {
               "Name": "Field1",
               "OutputName": "Document.Fields[Name=Field1].Value"
            },{
               "Name": "Items.Field1",
               "OutputName": "Fields[Name=ItemsField1].Value"
            }
         ]
      }
   ]
}

The following JSON data is generated from this configuration:

{
   "Document": {
      "Fields": [
         {
            "Name": "Field1",
            "Value": …
         }
      ],
      "Items": [
         {
            "Fields": [
               {
                  "Name": "ItemsField1",
                  "Value": …
               }
            ]
         }
      ],
      "Files": [
         {
            "Reference": "…",
            "Name": "…"
         }
      ]
   }
}