Skip to content

Numeric-key objects result in sparse arrays #66

@dharkness

Description

@dharkness

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.

{
  items: [
    {
      123: 'foo',
      456: 'bar'
    }
  ]
}

// dot.dot(obj)

{
  'items[0].123': 'foo',
  'items[0].456': 'bar'
}

But when you run that through dot.object(), you don't get the original object. You get a sparse array instead.

{
  items: [
    [
      ...123 empty slots...
      'foo',
      ...333 empty slots...
      'bar'
    ]
  ]
}

Is there an option to use objects for . in all cases, even when the key is an integer?

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