Solved

Create list from JSON attribute


Badge

Hi,

I can read the following JSON data from a file using the JSONFeature Reader and then attach a ListExploder to the list attribute named professionals-involved-in-the-discussion{}. This creates a row for each professional in the data. Perfect.

However, in reality this JSON is coming from an attribute named json_data (not a file). If I use a JSONFlattener transformer attached to the json_data attribute, I need to manually create the attributes to expose. I have created a professionals-involved-in-the-discussion attribute, but it is not accepeted by the ListExploder?

Any help would be appreciated as I guess I am missing something simple.

Many thanks.

 

{

 

"outcomes": ["testA"],

 

"party-id": 132956,

 

"start-date": "2017-06-21T12:38:00",

 

"activity-id": 10279532,

 

"assigned-to": 103576,

 

"completed-by": 103576,

 

"created-date": "2017-06-21T12:38:24.937000",

 

"authorised-by": 39583,

 

"completed-date": "2017-06-22T12:39:17.267000",

 

"authorised-date": "2017-06-24T09:23:34.010000",

 

"assigned-to-team": "team2",

 

"strategy-discusson-reason": {

 

"id": 6951,

 

"date-of-strategy-discussion": "2017-06-21",

 

"reason-for-strategy-discussion": "Info. "

 

},

 

"professionals-involved-in-the-discussion": [{

 

"id": 11733,

 

"name": "NS",

 

"agency": "Social Worker ",

 

"contact-details": "test.gov.uk"

 

},

 

{

 

"id": 11741,

 

"name": "MW ",

 

"agency": "Family Support ",

 

"contact-details": "test.gov.uk "

 

}]

 

}

icon

Best answer by jdh 10 May 2018, 16:49

View original

5 replies

Badge +22

When exposing the list attribute you need to include the curly braces {}.

 

Alternatively you can use a JSONFragmenter instead.

 

 

jsonlist.fmw

Badge

Thanks for your response, your example adding a flattener after the fragmenter worked to give me the columns on separated rows. Fantastic

Weirdly, the flattener followed by list exploder in your example still threw missing data?

Badge +22

Thanks for your response, your example adding a flattener after the fragmenter worked to give me the columns on separated rows. Fantastic

Weirdly, the flattener followed by list exploder in your example still threw missing data?

What version of FME are you using?

 

 

The listExploder works fine for me.

 

 

 

Badge
What version of FME are you using?

 

 

The listExploder works fine for me.

 

 

 

I get the 2 rows like you, but the inspector shows the missing tag?

 

inspector.png

 

 

Badge +22
I get the 2 rows like you, but the inspector shows the missing tag?

 

inspector.png

 

 

Since you exploded the list, the attributes that are present are:

 

id, name, agency, contact-details.

 

 

If you didn't explicitly expose them on the flattener/fragmenter (professionals-involved-in-the-discussion{}.id) they won't show up on the canvas, or by default in the table view of the inspector, but they are present on the feature, and can be seen with the logger or the feature information panel, or can be added to the table view by clicking on the columns button.

 

 

Reply