blob: ce11d7fd3d2a6699ec508097f78883967f03713e [file] [log] [blame] [view]
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01001[TOC](Readme.md) [Prev](stringlit.md) [Next](scopes.md)
2
Marcel van Lohuizenaf0932f2019-01-11 13:03:56 +01003_JSON Sugar and other Goodness_
4
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01005# Bytes
6
7CUE distinguishes between a `string` and a `bytes` type.
8Bytes are converted to base64 when emitting JSON.
9Byte literals are defined with single quotes.
10The 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 Amsterdame4790382019-01-20 10:29:29 -050014<!-- jba: this contradicts the spec, which has \nnn (no leading zero) -->
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010015
16<!-- CUE editor -->
17```
18a: '\x03abc'
19```
20
21<!-- JSON result -->
22```json
23{
24 a: "A2FiYw=="
25}
26```