Handling Arrays
Great package!
I have an issue with handling arrays. I'm using untranspose to convert into a mongodb modifier.
Input data looks like this:
{
tracking: true,
blocked: true,
nsfw: false,
categories: {
subscribed: [ 'xag2vJYrDJdsyZfah', 'abpxCb6pN3aR4piMw' ],
blocked: []
},
sources: {
subscribed: [ '4QSh8AqECuPauHFor' ],
blocked: []
}
}
Output data looks like this:
{
'tracking': true,
'blocked': true,
'nsfw': false,
'categories.subscribed[0]': 'xag2vJYrDJdsyZfah',
'sources.subscribed[0]': '4QSh8AqECuPauHFor'
}
I was expecting/would prefer this:
{
'tracking': true,
'blocked': true,
'nsfw': false,
'categories.subscribed': ['xag2vJYrDJdsyZfah', 'abpxCb6pN3aR4piMw'],
'sources.subscribed': ['4QSh8AqECuPauHFor']
}
Could we include an optional flag to not break down arrays? Also, it seems a little buggy in its current format because it only included the first array element not the second.
Hmmm, if it's not returning both item then that would be an issue.
As for it returning arrays - it's actually designed to flatten the object - including the nested arrays. We won't be able to change that functionality but I could look at adding some options to get some customized formatting possibly.
Can you shed some light on this one? I added a test but didn't see any missing items. Let me know what platform you saw that one on.
https://github.com/henrytseng/dataobject-parser/pull/15