Skip to content

Supporting different json list structure when retrieving data #62

@RaphSfeir

Description

@RaphSfeir

Hey there,

Currently, it seems that Dayron only supports data retrieval of endpoints that look like this:

[
    { "id": 0, "name": "Elem 1"},
    { "id": 1, "name": "Elem 2"}
]

Unfortunately I have to work with REST APIs that output data in a different way quite often. Some APIs add some additional metadata and therefore store the main result list in a specific property. Classic example:

{
"data": [
    { "id": 0, "name": "Elem 1"},
    { "id": 1, "name": "Elem 2"}
],
"count": 2
}

I made quick changes on my fork of Dayron that support this kind of data structure, those are tested in the model_test.ex file. I have also adressed this topic a bit in the README.MD file, as I feel it would have saved me a bit of time to have this specified in the readme.

Would you be interested in a pull request?

Note that some of our services also use the JSONApi.org specification, which is even more complex. Full support of JSONApi would probably be a big work (though if you are looking to build nested data mapping, you should check out how they handle it, it's quite interesting). However, I have also written small changes that allow Dayron to extract data from a JSONApi response. It's still quite early, it feels too unsure to push this publicly, but tell me if you're interested on this topic as well, as I will probably investigate it further.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions