0

I have below JSON input data coming from Queue

{
"ID": 0501,
"AssetId": "EFT0501"
}

JsonLint.com shows it's invalid JSON because number starts with 0.

In my .Net code, I'm able to parse this value but ID field value gets change.

Code

var test = JObject.Parse(message);

Output

{
"ID": 321,
"AssetId": "EFT0501"
}

Any suggestion Why is this value getting change? how to fix, If I can't change input format?

Pankaj Rawat
  • 4,037
  • 6
  • 41
  • 73
  • 12
    The number is interpreted as an octal number, 501 (octal) = 321 (decimal). – Dirk May 07 '19 at 12:24
  • 1
    https://stackoverflow.com/questions/27361565/why-is-json-invalid-if-an-integer-begins-with-a-leading-zero Seems like you will have to just store it as a string? – mouldycurryness May 07 '19 at 12:25
  • json does not support octal datatype, you have to change it to string or just receive it as decimal then change it back to octal.. – Donald May 07 '19 at 12:55

0 Answers0