JSON::= See http://www.json.org/.
[ JSON ]
(wikipedia entry).
Based on JSON above.
- #X::= "" | X #X.
- O(X)::= ""|X, optional.
- L(x)::= X | X "," L(X), lists.
- N(X)::= X #X.
Extra whitespace between lexemes are ignored.
- object::= "{" "}" | "{" L(member) "}".
- member::= string ":" value.
{"species":"Snake", "id":1234, "length":5.5, "male":true}
- array::="[" L(value) "]".
[1,4,9,16]
[true,false,true,false]
JSON arrays can be heterogenous
[1,true,"foo"]
with thanks to Laurent(5:30pm California time Apr 17 2012).
- value::= string | number | object | array | true | false| null.
- true::lexeme.
- false::lexeme.
- null::lexeme.
- string::=quotes quotes | quotes N(char) quotes.
- quotes::lexeme=
"\"".
- char::=any Unicode character except quotes or backslash or control character | escaped_character | unicoded_character.
- backslash::lexeme=
"\\".
- escaped_character::= backslash ( quotes | backslash | slash | "b" | "f" | "n"| "r" | "t").
TableEscaped Character | Meaning
|
---|
\" | "
|
\\ | \
|
\/ | /
|
\b | Backspace
|
\f | Formfeed
|
\n | Newline
|
\r | Return
|
\t | Horizontal tab
|
(Close Table)
- unicode_character::= hex_digit ^ 4, four hex digits.
- hex_digit::= "0..9" | ignore_case("A".."F"),
(Stephen Parker checked this out on April 17th 2012.
- number::= int | int frac | int exp | int frac exp.
- int::=O("-") ( digit | digit1_9 digits ).
- digits::= N(digit), 1 or more digits.
- digit::="0".."9".
- digit1_9::="1".."9".
- frac::= dot digits.
- exp::=e digits.
- dot::lexeme=
".".
- e::= ("e"|"E")O("+"|"-").
. . . . . . . . . ( end of section Syntax of JSON) <<Contents | End>>
Note: above needs some work!
JSON describes data/objects by a human readable interpretation of the different Values:
- JSON_Value::= String | Numbers | @ | {{}} | String <>-> JSON_Value | Nat0<>->JSON_Value.
The semantic sets map nicely into MATHS sets.
- String::=#Unicode.
[ maths/types.html#Unicode ]
- Numbers::=Integer | Real.
- Integer::= See http://csci.csusb.edu/dick/maths/logic_6_Numbers..Strings.html#Integer.
- Real::= See http://csci.csusb.edu/dick/maths/math_42_Numbers.html#Real Numbers.
We use a partial maps ( dom <>-> cod) to represent the meaning of JSON objects and arrays.
Nat0 is the standard symbol for the set of natural numbers including 0.
- Nat0::= See http://csci.csusb.edu/dick/maths/math_42_Numbers.html#Nat0.
Next we describe the meaning map from the syntax to the semantics.
The traditional symbol for this mapping is μ.
- μ::=meaning.
- meaning:: Value -> JSON_Value.
I define it "piecewise" on each type of value in turn --
- μ(true)::= STANDARD.true.
- μ(false)::= STANDARD.false.
- μ(null)::={}, possibly.
- μ("")::="".
- For m: Member, μ(m)::= (m.string +> m.value).
- For x:Object, μ(x)::= |[m:x.member]μ(x).
- For z:Array, TBD.
. . . . . . . . . ( end of section Semantics of JSON) <<Contents | End>>