Skip to main content
Solved

Reading attributes from JSON response

  • March 5, 2026
  • 3 replies
  • 38 views

havmoejbv
Contributor
Forum|alt.badge.img+16

I have JSON response from an API that looks a bit like this (tidied up for the purpose of showing here):

{
"member": [
{
"id": "OBF-123",
"fieldspec": [
{
"assetattrid": "FIELD01",
"assetattribute": [
{
"datatype": "NUMERIC",
"description": "Length"
}
],
"numvalue": 13.4
},
{
"assetattrid": "FIELD02",
"assetattribute": [
{
"datatype": "ALN",
"description": "Fruit type"
}
],
"alnvalue": "Banana"
},
{
"assetattrid": "FIELD03",
"assetattribute": [
{
"datatype": "ALN",
"description": "Class"
}
],
"alnvalue": "N"
}
]
},
{
"id": "OBF-124",
"fieldspec": [
{
"assetattrid": "FIELD02",
"assetattribute": [
{
"datatype": "ALN",
"description": "Fruit type"
}
],
"alnvalue": "Apple"
},
{
"assetattrid": "FIELD01",
"assetattribute": [
{
"datatype": "NUMERIC",
"description": "Length"
}
]
},
{
"assetattrid": "FIELD03",
"assetattribute": [
{
"datatype": "ALN",
"description": "Class"
}
],
"alnvalue": "K"
}
]
}
]
}

This defines the attributes for two objects returned from an API request, containing the field name (assetattrid) and alias (description), the field type (datatype) and finally the actual attribute value (numvalue/alnvalue). What I would like is to get properly named attributes like this:

id Length Fruit type Class
OBF-123 13.4 Banana N
OBF-124   Apple K

 

A few complicating factors (and why I’d like to find a dynamic solution):

  • The attributes (names, types and amounts) may be different depending on the data queried (different object types, query parameters etc)
  • Some fields might be empty, like the missing numvalue for object 2 above, but the field definition seems to always be there
  • The field order appears to be random

Best answer by hkingsbury

Find attached an example workspace (2024.2)

Its a pure dynamic workflow, so everything is data driven (exception of the ‘id’ field in the output)

The general logic is to:

  1. break down the incoming json so that each field in each record is a fme feature
  2. Create each feature using description as the attribute name and (aln|num)value as the attribute value
  3. Aggregate these back based on the id in the JSON
  4. Take one example of each field, build an fme schema object for them
  5. Join the schemas back onto the records
  6. write out (to csv) using the schema attached to the feature

 

3 replies

hkingsbury
Celebrity
Forum|alt.badge.img+69
  • Celebrity
  • Best Answer
  • March 5, 2026

Find attached an example workspace (2024.2)

Its a pure dynamic workflow, so everything is data driven (exception of the ‘id’ field in the output)

The general logic is to:

  1. break down the incoming json so that each field in each record is a fme feature
  2. Create each feature using description as the attribute name and (aln|num)value as the attribute value
  3. Aggregate these back based on the id in the JSON
  4. Take one example of each field, build an fme schema object for them
  5. Join the schemas back onto the records
  6. write out (to csv) using the schema attached to the feature

 


havmoejbv
Contributor
Forum|alt.badge.img+16
  • Author
  • Contributor
  • March 6, 2026

Oh, very nice! This seems to be working fine on the test data on my end and solves a massive headache I’ve had. Thank you!


danilo_fme
Celebrity
Forum|alt.badge.img+54
  • Celebrity
  • March 6, 2026

Find attached an example workspace (2024.2)

Its a pure dynamic workflow, so everything is data driven (exception of the ‘id’ field in the output)

The general logic is to:

  1. break down the incoming json so that each field in each record is a fme feature
  2. Create each feature using description as the attribute name and (aln|num)value as the attribute value
  3. Aggregate these back based on the id in the JSON
  4. Take one example of each field, build an fme schema object for them
  5. Join the schemas back onto the records
  6. write out (to csv) using the schema attached to the feature

 

Good job!