Skip to content

Response object switching from array to object value based on number of results #91

@rmzg

Description

@rmzg

A problem I frequently run into is when the value of a given key somewhat randomly switches between an array value and an object value. In my most recent they key is the ItemLookupResponse.Items.Item which sometimes contains an array and sometimes contains a single object which tends to cause errors like TypeError: Cannot read property 'length' of undefined.

Obviously the reason why it switches is because sometimes there's multiple values and sometimes there's a single value, which is why you can't use a generic function to translate XML in to JSON since they're not the same type of structure.

This can be worked around in the requiring code with some annoyance but would make for much simpler code if it was fixed in the library code, which in this case means that Items.Item should always be an array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions