Repeated Processing Instructions in Generic JSON

Additional declarations are required when extracting data from repeated structures below the record node. Declaration of a repeated node happens with the "[?Repeated [OptionalSpaceSeparatedFilters]?]" processing instruction. The "[?Repeated?]" instruction must be placed inside "[?Record?]" scope. For example:

Copy
{
  "Products": [
    {
  "ID": "EXA-5002-1004",
  "Values": [
    {
  "AttributeID": "52",
  "Value": "Some description text"
},
    {
  "AttributeID": "77",
  "Value": "53 kg"
}
  ]
}
  ]
}   

Note that the "Values" array contains multiple objects. To extract data from both occurrences, the template must declare that the array of objects is repeated, which means that a set of fields has to be generated for each node encountered. The template also has to declare an ID source in each object.

The following template could be used to extract the data from the above Generic JSON:

Copy
{
  "Products": [
    {
  "[?Instruction?]": "[?Record?]",
  "ID": "[?Source ID?]",
  "Values": [
    {
  "[?Instruction?]": "[?Repeated?]",
  "AttributeID": "[?SourceID?]",
  "Value": "[?Source?]"
}
  ]
}
  ]

The ID source is used to map each occurrence of a repeated object to a specific set of fields of the form [Identifier].[SourceTagName]. This is required to ensure that related repeated nodes map to the same fields across different records.

By default, a repeated scope produces a set of fields for each ID Source value encountered in the input document. Using the 'optional space separated filters' allows you to select values from specific ID keys or to guard against additional columns being generated as input documents evolve in the future.

Copy
{
  "ARTICLE": {
    "ARTICLE_PRICE_DETAILS": {
      "DATETIME": {
        "type": "valid_start_date",  
        "DATE": "2010-01-01"
      },
      "PRODUCT_PRICE": [
        {
          "price_type": "net_list",
  "PRICE_AMOUNT": 11.08,
          "PRICE_CURRENCY": "EUR",
          "TAX": 0.19,
          "LOWER_BOUND": 1
        },
        {
          "price_type": "nrp",
          "PRICE_AMOUNT": 23.05,
          "PRICE_CURRENCY": "EUR",
          "TAX": 0.19,
          "LOWER_BOUND": 1
        },
        {
          "price_type": "employee",
          "PRICE_AMOUNT": 8.52,
          "PRICE_CURRENCY": "EUR",
          "TAX": 0.19,
          "LOWER_BOUND": 1
        }
      ]
    }
  }
}    

The price and currency information can be extracted for the net_list and nrp price types only by following the proceeding steps and using the following template:

  1. Copy the above Generic JSON to a new file, and save as a JSON file
  2. Open Import Manager, select the file as the Data Source Filename, and click 'Next'
  3. The user can enter / paste the template below in the Import Manager, and a conversion preview can be generated by clicking the refresh button, .
Copy
{
  "ARTICLE": {
   "[?Instruction?]": "[?Record?]",
    "ARTICLE_PRICE_DETAILS": {
      "PRODUCT_PRICE": [
        {
          "[?Instruction?]": "[?Repeated net_list nrp?]",
          "price_type": "[?SourceID?]",
          "PRICE_AMOUNT": "[?Source Amount?]",
          "PRICE_CURRENCY": "[?Source Currency?]"
        }
      ]
    }
  }
}    

This produces the fields:

  • net_list.Amount = 11.08
  • net_list.Currency = EUR
  • nrp.Amount = 23.05
  • nrp.Currency = EUR

The "[?Repeated?]" instruction can take an arbitrary number of filter terms separated by white-space characters. When no terms are defined, the filtering functionality is disabled.