Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 1 | [TOC](Readme.md) [Prev](stringlit.md) [Next](scopes.md) |
| 2 | |
Marcel van Lohuizen | af0932f | 2019-01-11 13:03:56 +0100 | [diff] [blame] | 3 | _JSON Sugar and other Goodness_ |
| 4 | |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 5 | # Bytes |
| 6 | |
| 7 | CUE distinguishes between a `string` and a `bytes` type. |
| 8 | Bytes are converted to base64 when emitting JSON. |
| 9 | Byte literals are defined with single quotes. |
| 10 | The following additional escape sequences are allowed in byte literals: |
| 11 | |
| 12 | \xnn // arbitrary byte value defined as a 2-digit hexadecimal number |
| 13 | \0nnn // arbitrary byte value defined as a 3-digit octal number |
Jonathan Amsterdam | e479038 | 2019-01-20 10:29:29 -0500 | [diff] [blame^] | 14 | <!-- jba: this contradicts the spec, which has \nnn (no leading zero) --> |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 15 | |
| 16 | <!-- CUE editor --> |
| 17 | ``` |
| 18 | a: '\x03abc' |
| 19 | ``` |
| 20 | |
| 21 | <!-- JSON result --> |
| 22 | ```json |
| 23 | { |
| 24 | a: "A2FiYw==" |
| 25 | } |
| 26 | ``` |