Atomics

Figure 11. Literal

Literal

Figure 12. NumericLiteral

NumericLiteral

Figure 13. IntegerLiteral

IntegerLiteral

Figure 14. DecimalLiteral

DecimalLiteral

Figure 15. DoubleLiteral

DoubleLiteral

Figure 16. StringLiteral

StringLiteral

Figure 17. BooleanLiteral

BooleanLiteral

Figure 18. NullLiteral

NullLiteral

The syntax for creating strings, numbers, booleans and nulls is identical to that of JSON (it is actually a more flexible superset, for example leading 0s are allowed, and a decimal literal can begin with a dot). Note that JSONiq distinguishes between integers (no dot, no scientific notation), decimals (dot but no scientific notation) and doubles (scientific notation). As expected, an integer literal creates an atomic of type integer, and so on. No surprises. JSON's backslash escaping is supported in string literals. Also, like in JSON, double quotes are required and single quotes are forbidden.

Example 16. String literals

"foo"
      

Result: foo


Example 17. String literals with escaping

"This is a line\nand this is a new line"
      

Result: This is a line and this is a new line


Example 18. String literals with Unicode character escaping

"\u0001"
      

Result: 


Example 19. String literals with a nested quote

"This is a nested \"quote\""
      

Result: This is a nested "quote"


Example 20. Integer literals

42
      

Result: 42


Example 21. Decimal literals

3.14
      

Result: 3.14


Example 22. Double literals

+6.022E23
      

Result: 6.022E23


Example 23. Boolean literals (true)

true
      

Result: true


Example 24. Boolean literals (false)

false
      

Result: false


Example 25. Null literals

null
      

Result: null