You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@dharkness unsure if you're still dealing with this problem, but I seem to have found a workaround. Fortunately or unfortunately, you will need to modify your code a bit to init a Dot class, with the useArray flag set to false:
const util = new dot('.', false, false, true);
Once that's done, you can run the object method on your object and you should get the results you're expecting:
let dot = require('dot-object');
let util = new dot('.', false, false, true);
let data = {
items: [
{
123: 'foo',
456: 'bar'
}
]
};
let results = util.object(data);
where results is { items: [ { '123': 'foo', '456': 'bar' } ] }
Reading through some of the other issues, it seems this may be intended behavior. We have enabled the option to output brackets around array indices.
But when you run that through
dot.object()
, you don't get the original object. You get a sparse array instead.Is there an option to use objects for
.
in all cases, even when the key is an integer?The text was updated successfully, but these errors were encountered: