cancel
Showing results for 
Search instead for 
Did you mean: 

How to read in multiple JSON files with DataSource and parse when # of child nodes differs ?

Contributor

How to read in multiple JSON files with DataSource and parse when # of child nodes differs ?

I am reading in 400+ JSON files from a directory using DataSource.

 

  • Each individual JSON file is imported into a test step property using DataSource test step with Source = Directory
  • I am then using DataSource test step with Source = JSON to read in the JSON from the test step property for parsing.
  • I want to do this in nested DataSourceLoops so that for each of the 400+ files I am reading in all the combinations of tableName and columns
  • The number of tableNames and columns varies by file, but the structure of all files is identical 
  • Desired output is listed below.  I am able to loop through the files and successfully obtain the ontologyName and the table names, but having difficulty with the column names

Can anyone help?   Scroll down for desired output and raw JSON.  Thanks!

 

Capture.JPG

 

Capture1.JPG{

JSON FILE 1

{
  "ontologyName": "Resource01",
  "linkedResources": [
    {
      "tableName": "Table01",
      "columns": [
        "Resource01 - Table01 - a_reference",
        "Resource01 - Table01 - b_reference",
        "Resource01 - Table01 - c_reference",
        "Resource01 - Table01 - d_reference",
        "Resource01 - Table01 - e_reference"
      ]
    }
  ]
}

JSON FILE 2

{
  "ontologyName": "Resource02",
  "linkedResources": [
    {
      "tableName": "Table01",
      "columns": [
        "Resource02 - Table01 - a_reference",
        "Resource02 - Table01 - b_reference"
      ]
    },
    {
      "tableName": "Table02",
      "columns": [
        "Resource02 - Table02 - a_reference",
        "Resource02 - Table02 - b_reference",
        "Resource02 - Table02 - c_reference"
      ]
    },{
      "tableName": "Table03",
      "columns": [
        "Resource02 - Table03 - a_reference",
        "Resource02 - Table03 - b_reference",
        "Resource02 - Table03 - c_reference",
        "Resource02 - Table03 - d_reference",
        "Resource02 - Table03 - e_reference"
      ]
    }
  ]
}

 

1 REPLY 1
Moderator

Re: How to read in multiple JSON files with DataSource and parse when # of child nodes differs ?

New Here?
Join us and watch the welcome video:
Top Kudoed Authors