Open Vedan opened 4 years ago
Q. Which is the type of 1
?
int
uint
long
ulong
byte
sbyte
short
ushort
float
double
decimal
Yeah,we cannot answer this question.
Hi. You need parce by maximum. For Example: if from 0 to 255 - this is a Byte from 255 to 65535 this is a short and next. Float and double you can parce by decimal symbol for example 2.3 this is a float. This is will be a more correct and logically for better understand and coding. If you build this parcer in UTF8Json - this is will be a cool. Thank you. Paul
Hi.
You need parce by maximum. For Example: if from 0 to 255 - this is a Byte from 255 to 65535 this is a short and next.
I think that's really confusing. Maybe you are already confused. Why it is not a sbyte from 0 to 127?
You can parce an SByte. I am not using this type and showed example with Byte. you can analise types: 1 byte in + and - Byte (SByte) 2 byte in + and - 4 byte + and - 8 byte + and - and float and double by decimal symbol
I have these issues about your proposal.
Originally,the type of every number in JSON is number
of JavaScript.
number
of JavaScript is a representation of double-precision floating point number.
Representation of double-precision floating point number in .NET is System.Double
,it is double
in C#.
Precision
float
.and decimal
has different precision from double
.
I did not quite understand the question. (English is not my mother lang) You can determine the fractional data type by the separator character. If there is no separation sign, then this is an integer and that’s it. Next, you determine the dimension by the value of the number. Usually used only types of byte, short, int, long, float, double. From string convert you can use 1) if has symbols "." or"," - than is fractional and than float.TryParce() and if return false than double.TryParce(). 2) else if has only digits from 0 to 9 - this is a byte.TryParce() is return false short.TryParce() is return false int.TryParce() is return false long.TryParce()
I didn't mean precision of type-expection. I said about difference of precision between floating point number types. Number in JSON should have precision of double-precision floating point number.
Hello!
I am found than bug. Serialise long type for example (2610758670492575612) but after read has Double. Bug in read method. string s1 = @"[{""Pack_Num"": 30459,""ID"": 2610758670492575612,""Location"": ""clSpire#11635"",""Item"": ""clItem#23887""}]"; bb = Encoding.UTF8.GetBytes(s1); List<Dictionary<string, object>> d2 = JsonSerializer.Deserialize<List< Dictionary<string, object>>>(bb);
in d2[0]["ID"] - has Double but need long.
Regards, Paul