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

Merge nested objects together #7

Open
OliverFischer opened this issue May 17, 2017 · 1 comment
Open

Merge nested objects together #7

OliverFischer opened this issue May 17, 2017 · 1 comment
Labels

Comments

@OliverFischer
Copy link

Hi altogether, I have a simple question:

DataObjectParser.prototype.set overwrites property sections complete when adding properties to the resulting model. Is it possible to add a merge mechanism like $obj[$key] = _.merge($obj[$key]||{},$data); in line 35 in dataobject-parser.js? So nested properties can survive in the merge process like in this example:

dataobjParser.set('a',{projectId : 'common',route : 'a',fragment:{key : 'looser', anotherProp : 'I will survive'}})
dataobjParser.set('a', {projectId : 1, route : 'a',fragment:{key : 'winner'}})

I would like to see the the property 'anotherProp' from the first object even when overwriting the second one...

Greetings Olli

@henrytseng
Copy link
Owner

Not comfortable with adjusting behavior of set method but we could add a merge method so as to fit your needs.

@henrytseng henrytseng added the wip label Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants