dot-object icon indicating copy to clipboard operation
dot-object copied to clipboard

dot.object fails converting numeric nested json object

Open jelhub opened this issue 5 years ago • 1 comments

Example:

const dot = require('dot-object')

const config = {
  level1: {
	key1: 'val1',
	2222: {
	  key2: 'val2'
	}
  },
  3333: {
	key3: 'val3'
  }
}

console.log('original:')
console.log(config)
console.log()

const dotConfig = dot.dot(config)

console.log('should be the same as original:')
console.log(dot.object(dotConfig))

Output shows:

original:
{
  '3333': { key3: 'val3' },
  level1: { '2222': { key2: 'val2' }, key1: 'val1' }
}

should be the same as original:
{
  '3333': { key3: 'val3' },
  level1: [ <2222 empty items>, { key2: 'val2' }, key1: 'val1' ]
}

jelhub avatar Jan 27 '20 10:01 jelhub

Found the solution: https://stackoverflow.com/a/7794127

hey0wing avatar Oct 29 '21 03:10 hey0wing