Generic JSON Import References and Links Example

Using the Import Manager, this example demonstrates how to take a JSON input document to create a template, then modify the template to resolve errors and accurately read the input, and prepare the data for mapping.

The following is an example of a JSON Import for product records that contain a Name, PointType, PrimaryImage, AdditionalImages, ProductReferences, and Supplier attributes. The Name, PointType, PrimaryImage and Supplier attributes are single values and use the [?Source?] instruction in the JSON template below. The AdditionalImages array and ProductReferences object array included in the import example are mapped to references in STEP and use the "[?MultiSource?]" instruction in the JSON template below to handle multiple reference targets. There are some limitations with what can be transformed by the JSON template and what can be mapped using the Import Manager, therefore references of different types in an array cannot be mapped using the [?Repeated?] and [?SourceID?] instructions and when multiple references of the same type are included in an object array, the metadata cannot be mapped. However, a single reference target can be mapped to accept metadata on the reference using the Reference Meta-Data mapping option.

Input Document

For this example import, copy the following text to a new file and save it as a JSON file. Open the Import Manager and select the file as the Data Source Filename and click 'Next.'

Copy
{
  "Products": [
      {
        "Name": "Pilot Pen",
"PointType": "Fine",
"PrimaryImage": "http://stationarysupplies.com/images/products/g23--red.JPG",
"AdditionalImages": [
"http://stationarysupplies.com/images/products/g2710003.jpg",
"http://stationarysupplies.com/images/products/gmac4001f.jpg",
"http://stationarysupplies.com/images/products/g2710002.jpg",
"http://stationarysupplies.com/images/products/g2710011.jpg",
"http://stationarysupplies.com/images/products/mpuc5002f.jpg"
],
        "ProductReferences": [
{
  "id": "732654001",
  "ExpirationDate": "2025-01-01",
  "Order": 1
},
{
  "id": "998356702",
  "ExpirationDate": "2025-01-01",
  "Order": 3
},
{
  "id": "900874519",
  "ExpirationDate": "2025-01-01",
  "Order": 2
}
        ],
"Supplier": "AcmeSupplier"
      },
      {
        "Name": "Parker Pen",
"PointType": "Medium",
"PrimaryImage": "http://stationarysupplies.com/images/products/parker-jotter-xl-mono-gold-pen.jpg",
"AdditionalImages": [
"http://stationarysupplies.com/images/products/parker-jotter-xl-mono-gold-pen.jpg",
"http://stationarysupplies.com/images/products/Parker-jotter-xl-mono-gold-ballpoint.jpg"
],
        "ProductReferences": [
{
  "id": "149256",
  "ExpirationDate": "9999-12-31",
  "Order": 1
},
{
  "id": "752301",
  "ExpirationDate": "2027-08-07",
  "Order": 2
}
        ],
"Supplier": "AcmeSupplier"
      }
    ]
}

Template

In this template:

  • Redundant objects in the "Products" and "ProductReferences" arrays have been removed.

  • The "[?Instruction?]": "[?Record?]" definition is added inside the first object in the Products array. "

  • [?Source?]" replaces values for "Name", "PointType", “PrimaryImage”, and “Supplier” attributes without using the optional identifiers.

  • In the "ProductReferences" array, the "[?MultiSource?]" instruction is added in place of the values for each of the attributes within the respective objects with optional identifiers.

Copy
{
  "Products": [
      {
        "[?Instruction?]": "[?Record?]",
        "Name": "[?Source?]",
        "PointType": "[?Source?]",
        "Colors": "[?MultiSource?]",
        "PrimaryImage": "[?Source?]",
        "AdditionalImages": "[?MultiSource?]",
        "ProductReferences": [
{
  "id": "[?MultiSource Prod Ref ID?]",
  "ExpirationDate": "[?MultiSource Prod Ref Expire?]",
  "Order": "[?MultiSource Prod Ref Order?]"
}
        ],
        "Supplier": "[?Source?]"
      }
    ]
}

Conversion Preview

In the Conversion Preview section of the Import Manager's Select Format step, the template results in the values from the "ProductReferences" objects in arrays being concatenated with a semicolon separator. There are three product references in the JSON, based on the semicolon-separated values in each column, along with metadata in the adjacent columns.

Click the Sample reload button, . The Conversion Preview area displays the results of the input document against the provided template.

After clicking the Next button, the mapping step is presented where the Name and PointType attributes have been mapped. To map the next three columns and the last column, the Reference mapping uses the relevant reference type or classification link types and Target ID Aspect using Keys configured on the system to match the value(s).

Since the Reference Meta-Data mapping does not support multiple references, the example prioritizes the creation of the target references, by mapping to the Prod Ref ID column, while ignoring the columns that include Prod Ref Expire and Prod Ref Expire attributes. For [?MultiSource?] mappings, like “AdditionalImages,” adding a multi-value transformation is required to recognize the individual values, which are matched on the AssetDownload.AssetURLKey.

When the import completes successfully, the new Products are created with references and classification links populated as defined in the JSON document.