当前位置:网站首页>JSON Library Tutorial from scratch (II): parsing digital learning and sorting notes

JSON Library Tutorial from scratch (II): parsing digital learning and sorting notes

2022-06-25 05:17:00 zhongh58

Original website : From scratch JSON Library Tutorial - You know

JSON Number syntax

number = [ "-" ] int [ frac ] [ exp ]
int = "0" / digit1-9 *digit
frac = "." 1*digit
exp = ("e" / "E") ["-" / "+"] 1*digit

number Is expressed in decimal , It is mainly composed of 4 Part order consists of : Minus sign 、 Integers 、 decimal 、 Index . Only integers are required . The difference between attention and intuition may be , A plus sign is illegal .

If the integer part is 0 Start , It can only be a single 0; And by the 1-9 At the beginning , You can add any number of numbers (0-9). in other words ,0123 Not a legal one JSON Numbers .

The decimal part is more intuitive , Is one or more numbers after the decimal point (0-9).

JSON Scientific notation can be used , The index part is capitalized E Or lowercase e Start , Then there can be a sign , Followed by one or more numbers (0-9).

 C Library function - strtod()

C Library function  double strtod(const char *str, char **endptr)  Put parameters  str  The string pointed to is converted to a floating point number ( The type is double type ). If  endptr  Not empty , The pointer to the character after the last character in the conversion will be stored in endptr The location of the reference .

-> Priority ratio * high

原网站

版权声明
本文为[zhongh58]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210518428395.html