Newtonsoft.json: Deserializing a number with a leading zero

Created on 31 May 2016  路  1Comment  路  Source: JamesNK/Newtonsoft.Json

For example

{ "number":0100 }

if look at JsonTextReader.ParseNumber() you can see

long value2 = text2.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? Convert.ToInt64(text2, 16) : Convert.ToInt64(text2, 8);

it can throw System.FormatException (ex.: "09999").

In ECMA-404 The JSON Data Interchange Standard number must be only in 10base.

>All comments

Json.NET handles them an octal in JsonTextReader. It is by design.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Phreak87 picture Phreak87  路  11Comments

schani picture schani  路  11Comments

dmoeff picture dmoeff  路  17Comments

azzlack picture azzlack  路  38Comments

danebou picture danebou  路  18Comments