on 5e6a67f help sign in
41 lines 544 B history raw
1### `++jesc`
3Escape JSON character
5Produces a [`++tape`]() of an escaped [`++json`](/doc/hoon/library/3bi#++json) character `a`.
7Accepts
8-------
10`a` is an atom of odor [`@tD`](), aka a [`++char`]().
12Produces
13--------
15A [`++tape`]().
17Source
18------
20 ++ jesc
21 |= a=@ ^- tape
22 ?+ a [a ~]
23 10 "\\n"
24 34 "\\\""
25 92 "\\\\"
26 ==
27 ::
29Examples
30--------
32 ~zod/try=> (jesc 'a')
33 "a"
34 ~zod/try=> (jesc 'c')
35 "c"
36 ~zod/try=> (jesc '\\')
37 "\\"
38 ~zod/try=> (jesc '"')
39 "\""