Skip to main content
Solved

Use ODATA Reader to read nested complex types (arrays)


_fabian_
Contributor
Forum|alt.badge.img+5

I’m trying to retrieve data from a nested JSON response of an ODATA Feed.

For testing, I try to access the “Emails” property of this ODATA example service: https://services.odata.org/V4/(S(hg4u5ox0x0r2rjva5qwwra05))/TripPinServiceRW/People

The JSON structure is as follows:

{
    "@odata.id": "http://services.odata.org/V4/(S(hg4u5ox0x0r2rjva5qwwra05))/TripPinServiceRW/People('russellwhyte')",
    "@odata.etag": "W/\"08DC9753B5381A6D\"",
    "@odata.editLink": "http://services.odata.org/V4/(S(hg4u5ox0x0r2rjva5qwwra05))/TripPinServiceRW/People('russellwhyte')",
    "UserName": "russellwhyte",
    "FirstName": "Russell",
    "LastName": "Whyte",
    "Emails": [
        "Russell@example.com",
        "Russell@contoso.com"
    ],
    "AddressInfo": [
        {
            "Address": "187 Suffolk Ln.",
            "City": {
                "CountryRegion": "United States",
                "Name": "Boise",
                "Region": "ID"
            }
        }
    ],
    "Gender": "Male",
    "Concurrency": 638551632958200400
}

 

The “Emails” property is a complex type property, which should be able to be read by the readers documentation.

Each entry represents a structured record with a key that has a list of properties of primitive or complex types.

 

But when using the ODATA reader, only the simple properties get returned:


Is there any possibility to read nested properties (JSON objects/arrays) or do I have to resort to using a HTTPCaller?

Best answer by debbiatsafe

Hello @_fabian_ 

It appears the OData reader does not currently support reading Complex Type properties within a Complex Type. FMEENGINE-40129 tracks improving support for OData version 4, which should add support for reading nested complex type properties.

You may need to read the OData feed with an HTTPCaller and parse the JSON response with JSON transformers. Attached is a simple workspace demonstrating this approach, and I hope it helps.

View original
Did this help you find an answer to your question?

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • Best Answer
  • June 28, 2024

Hello @_fabian_ 

It appears the OData reader does not currently support reading Complex Type properties within a Complex Type. FMEENGINE-40129 tracks improving support for OData version 4, which should add support for reading nested complex type properties.

You may need to read the OData feed with an HTTPCaller and parse the JSON response with JSON transformers. Attached is a simple workspace demonstrating this approach, and I hope it helps.


_fabian_
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 1, 2024
debbiatsafe wrote:

Hello @_fabian_ 

It appears the OData reader does not currently support reading Complex Type properties within a Complex Type. FMEENGINE-40129 tracks improving support for OData version 4, which should add support for reading nested complex type properties.

You may need to read the OData feed with an HTTPCaller and parse the JSON response with JSON transformers. Attached is a simple workspace demonstrating this approach, and I hope it helps.

That’s a pity 😔 Looking forward to the improved reader! Thanks for the quick reply and clarifying the current limitations.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings