Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the map specifies an array and the underlying data is an object, it should be presented as an array #64

Open
switzer opened this issue Oct 14, 2019 · 1 comment

Comments

@switzer
Copy link

switzer commented Oct 14, 2019

If there is an underlying data structure as follows:

var src = {foo: {bar: 'baz'}}

And the map is as follows:

var map = { 'foo[].bar': 'abc[].def' }

Note that the src does not have an array at foo, but the mapping definition does. I'd like the output to be:

var expect = { abc: [ {def: baz} ] }

Currently, object mapper will not return any data, which is technically correct. However, to deal with APIs that don't behave well it would be nice to be able to identify that the underlying data structure is an object rather than array and put it into an array.

switzer pushed a commit to switzer/node-object-mapper that referenced this issue Oct 14, 2019
@switzer
Copy link
Author

switzer commented Oct 14, 2019

Note that the current functionality is that if an object is specified and the underlying data is an array, we automatically take the first node. This is the opposite case - e.g. an array is specified and the underlying data is an object. This should work the same way - I think this is a bug and not a feature. Note that none of the tests break when this fix is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant