Skip to main content

Like others, I've also been stumped on how to do this after trying variations of the JSON transformers.

Can someone upload an FME sample snippet or provide detailed instructions on how this can be accomplished?

Thank you in advance!!

 

I have the following JSON which contains an array within an array.

I'd like to:

  • extract the TaskListType from the 1st array (MaintPlanData)
  • extract the OperationNum and OperationDesc values from the 2nd array (TaskListItems)
  • and put them into a row/column format like the example below.

 

TaskListType OperationNum OperationDesc

ABC 0010 Execute

ABC 0030 Technician

ABC 0040 Record

EFG 0010 Execute

etc

 

{

 "RemainRecCount": 0,

 "MaintPlanData": o

  {

   "ScheduleIndPlan": 1,

   "PlanItems": {

    "ItemNum": 1234,

    "TaskList": {

     "TaskListType": "ABC",

     "TaskListItems": Â

      {

       "OperationNum": "0010",

       "OperationDesc": "Execute"

      },

      {

       "OperationNum": "0030",

       "OperationDesc": "Technician"

      }

     ]

    }

   },

   "PlanCycles": {

    "Counter": "00"

   }

  },

  {

   "ScheduleIndPlan": 1,

   "PlanItems": {

    "ItemNum": 1,

    "TaskList": {

     "TaskListType": "EFG",

     "TaskListItems":  

      {

       "OperationNum": "0010",

       "OperationDesc": "Execute"

      },

      {

       "OperationNum": "0030",

       "OperationDesc": "Operator"

      },

      {

       "OperationNum": "0040",

       "OperationDesc": "Record"

      }

     ]

    }

   },

   "PlanCycles": {

    "Counter": "01"

   }

  }

 ]

}

Hi @rsuinn​ 

One method you can use is to use two JSONFragmenters consecutively. The first transformer gets the TaskListType value on the feature and the second breaks the remaining JSON fragment to get individual TaskListItems array values.


Hi @rsuinn​ 

One method you can use is to use two JSONFragmenters consecutively. The first transformer gets the TaskListType value on the feature and the second breaks the remaining JSON fragment to get individual TaskListItems array values.

Your solution did work Thank you very much!

FME 2019.2

 

Hope this forum posting helps others.

 

the following worked for me and hopefully I'm explaining this right. Correct me if I'm wrong.

Basically I chained several JSON Fragmenters together.

  • I used an HTTPCaller to connect to and query a REST service which returned data in a JSON format.
  • A Tester was used to check the returned _http_status_code for REST errors
  • An Attribute Keeper is used to only keep the JSON data
  • JSON fragmenter 6 gets everything in the 1st JSON array (MaintPlanData) and displays JSON names at this level (e.g SchedIndPlan)
  • JSON fragmenter7 gets everything in the PlanItems name and displays JSON names at this level (e.g ItemNum)
  • and finally JSON fragmenter 8 gets everything in the 2nd JSON array (TaskListItems) and displays JSON names at this level (e.g OperationNum and OperationDesc)

 

The output looks like this (I mocked it up to replace real values with made up values)

FME2 

Here's what my workflow ended up as

 

FME1 

 

Note: the Attributes to Expose in the screenshots below are different from the steps and FME output above bc my actual JSON data had more fields than the example. The JSON names you put in the Attributes to Expose are what appears in the FME output.

 

FME3FME4FME5


Reply