RyanMarcus / dirty-json

A parser for invalid JSON
GNU Affero General Public License v3.0
294 stars 30 forks source link

Remove leading zeros #26

Open Erkin97-zz opened 4 years ago

Erkin97-zz commented 4 years ago

Hi, when you have an unquoted string with leading zeros it removes zeros.

{ "id": 00000111 } -> { "id": 111 } or { "id": A00000111 } -> { "id": "A111" }

I think it's related to Number conversion, but not sure.

RyanMarcus commented 4 years ago

Huh, that's a weird one! I think the "right" behavior in the first case would either be to treat the number as octal (like in JS) or to do what the parser currently does. In the second case, I would expect

{"id": "A00000111"}

I'll take a look at this soon.