Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialization exception #2986

Open
sunyuliang opened this issue Oct 10, 2024 · 2 comments
Open

Deserialization exception #2986

sunyuliang opened this issue Oct 10, 2024 · 2 comments

Comments

@sunyuliang
Copy link

Input string '0355264698' is not a valid number. Path 'Time', line 1, position 151.
Newtonsoft.Json.JsonReaderException: Input string '0355264698' is not a valid number. Path 'Time', line 1, position 151.
---> System.FormatException: Additional non-parsable characters are at the end of the string.
at System.ParseNumbers.StringToLong(ReadOnlySpan`1 s, Int32 radix, Int32 flags, Int32& currPos)
at System.Convert.ToInt64(String value, Int32 fromBase)
at Newtonsoft.Json.JsonTextReader.ParseReadNumber(ReadType readType, Char firstChar, Int32 initialPosition)
--- End of inner exception stack trace ---
at Newtonsoft.Json.JsonTextReader.ParseReadNumber(ReadType readType, Char firstChar, Int32 initialPosition)
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)

Source/destination types

JsonConvert.DeserializeObject<Dictionary<string, object>>(str);

Source/destination JSON

{"DeviceCode":"PESO0230","ProductCode":"resistance","DATE":"19810405075902","NUM":"33596","R1":"7.046000","R2":"0.000000","LEN":"0.0","Time":0355264698}

Expected behavior

Actual behavior

Steps to reproduce

// Your calls to Newtonsoft.Json here
@elgonzo
Copy link

elgonzo commented Oct 10, 2024

Input string '0355264698' is not a valid number.

The error is correct. This is not a bug.
Please check the json format specification. For numeric values, the json format does NOT allow leading zero digits (except a single zero digit in front of a decimal point, or a lone zero digit representing the value zero).

@majid3ma
Copy link

majid3ma commented Oct 11, 2024

The JSON you provided is invalid. Please check the element of time, it should be in double quotes like this below.

{"DeviceCode":"PESO0230","ProductCode":"resistance","DATE":"19810405075902","NUM":"33596","R1":"7.046000","R2":"0.000000","LEN":"0.0","Time":"0355264698"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants