remix-typedjson
remix-typedjson copied to clipboard
Meta keys can be incorrect when there is an empty string property
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.
So you beat me at debugging, came here to make the exact same issue 😄
Thanks for the bug report. I never considered empty keys before.