Skip to main content
Solved

Create list from JSON attribute

  • May 10, 2018
  • 5 replies
  • 750 views

Forum|alt.badge.img

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 "

 

}]

 

}

Best answer by jdh

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

 

Alternatively you can use a JSONFragmenter instead.

 

 

jsonlist.fmw

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • Best Answer
  • May 10, 2018

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

 

Alternatively you can use a JSONFragmenter instead.

 

 

jsonlist.fmw


Forum|alt.badge.img

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?


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • May 10, 2018

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.

 

 

 


Forum|alt.badge.img
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

 

 


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • May 10, 2018
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.