Home > Net >  Can anyone please explain this chart of JSON number values
Can anyone please explain this chart of JSON number values

Time:11-29

enter image description here

just explanation in a nutshell would help about this chart I am not able to understand the illustrations of this data value which is a number

CodePudding user response:

I read it as:

Can start with an optional "-"
Then either
    0
    OR
    1-9 followed by zero or more 0-9
Then an optional "." followed by one or more 0-9
Then an optional "e" or "E" (scientific notation)
    Optionally followed by either " " or "-"
    Then 1 or more 0-9 

CodePudding user response:

Generally, you follow the line from left to right. When it forks in two or more directions, you can take any one path. A green circle indicates a constant; a green box indicates a choice from 2 or more values. Often, a branch offers no choice, in which case you just keep going straight. Eventually, all divergent branches meet up again to proceed to the next choice.

The most confusing part is deciding what each intersection means. For that, you need to look carefully at the curve. You either peel away from the path, or you merge into the path; sometimes, the direction you are moving determines which is happening.

For example,starting at the far left, we immediately hit a branch which says we can start with a - or do nothing. After the choice is made, the two branches come together again, then immediately branch apart again: we can choose a 0 or a non-zero digit. If we choose the 0 branch, we do nothing until the next branch (which chooses between a . and nothing). If w choose the digit branch, we take a non-zero digit, the branch up to the decision point following the 0 or we pick any digit and decide again.

Basically, this is a drawing of a state machine corresponding to a regular expression like

-?(0|([1-9][0-9]*))(.[0-9] )?((e|E)( |-)?[0-9] )?

More intuitively, an optional negative sign, followed by a single 0 or an integer with no leading 0, followed by an optional fractional part (allowing unlimited trailing 0s), followed by an optional integer exponent consisting prefixed with either e or E and an optional sign.

  •  Tags:  
  • json
  • Related