remix-typedjson icon indicating copy to clipboard operation
remix-typedjson copied to clipboard

Meta keys can be incorrect when there is an empty string property

Open ericallam opened this issue 1 year ago • 2 comments

Recently tracked down this weird edge case where there is a nested object with a key that is an empty string and the value is [{}] resulting in meta keys being incorrect after the serialization encounters it. I've added this test case that recreates it.

The offending data here:

const edgeCase = { 
 nested: {
    '': [{}],
     bigint: BigInt(1),
  },
}

The expected value is

'{"nested":{"":[{}],"bigint":"1"},"__meta__":{"nested.bigint":"bigint"}}'

But the actual is:

'{"nested":{"":[{}],"bigint":"1"},"__meta__":{"bigint":"bigint"}}'

My guess is that there is somewhere doing a conditional on the "" value which will return false.

ericallam avatar Oct 06 '23 10:10 ericallam

So you beat me at debugging, came here to make the exact same issue 😄

valstu avatar Oct 06 '23 11:10 valstu

Thanks for the bug report. I never considered empty keys before.

kiliman avatar Oct 06 '23 13:10 kiliman