On this page:
gen:  To  JSON
->json
json->string
json->byte
8.6

3.1 JSON

提供稍微便利的json操作写法。

转成json的接口,需最小实现->json

procedure

(->json a)  jsexpr?

  a : gen:ToJSON
将可转的数据,转成jsexpr?

procedure

(json->string a)  string?

  a : gen:ToJSON
a转化成string?

Examples:
> (json->string "hello")

"\"hello\""

> (json->string 1)

"1"

> (json->string (list 1 (list "hello") "world"))

"[1,[\"hello\"],\"world\"]"

procedure

(json->byte a)  bytes?

  a : gen:ToJSON
a转化成bytes?

Examples:
> (json->byte "hello")

#"\"hello\""

> (json->byte (list 1 (list "hello") "world"))

#"[1,[\"hello\"],\"world\"]"