XU XUv0.8.8
EN

API

#encoding/json

import: #encoding/json

counts: 8 函数, 27 方法, 1 类型, 0 常量, 0 方法集

严格 JSON;parse 得池化 Doc。valid/compact/indent/quote。

struct Doc

XuAPI
pub struct Doc {
    pub kinds []int
    pub texts []string
    pub keys []string
    pub firsts []int
    pub nexts []int
    pub lasts []int
    pub root_idx int
    pub err string
    pub line int
    pub raw string
    pub i int
}

用途

公开结构体 `Doc`。

参数

kinds []int
字段([]int)
texts []string
字段([]string)
keys []string
字段([]string)
firsts []int
字段([]int)
nexts []int
字段([]int)
lasts []int
字段([]int)
root_idx int
字段(int)
err string
错误
line int
字段(int)
raw string
字段(string)
i int
下标或整数

(Doc) ok

XuAPI
pub fn (d Doc) ok() bool

用途

在 `Doc` 上调用 `ok`。

参数

d Doc
接收者 Doc(值接收者)

返回

bool — 是否成立

(Doc) error

XuAPI
pub fn (d Doc) error() string

用途

`Doc` 上的方法:错误。

参数

d Doc
接收者 Doc(值接收者)

返回

string — 结果字符串

(Doc) error_line

XuAPI
pub fn (d Doc) error_line() int

用途

`Doc` 上的方法:错误line。

参数

d Doc
接收者 Doc(值接收者)

返回

int — 该类型的值

(Doc) root

XuAPI
pub fn (d Doc) root() int

用途

在 `Doc` 上调用 `root`。

参数

d Doc
接收者 Doc(值接收者)

返回

int — 该类型的值

(Doc) kind

XuAPI
pub fn (d Doc) kind(n int) int

用途

在 `Doc` 上调用 `kind`。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(Doc) is_dict

XuAPI
pub fn (d Doc) is_dict(n int) bool

用途

`Doc` 上的方法:判断是否 dict。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) is_list

XuAPI
pub fn (d Doc) is_list(n int) bool

用途

`Doc` 上的方法:判断是否 list。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) is_string

XuAPI
pub fn (d Doc) is_string(n int) bool

用途

`Doc` 上的方法:判断是否 string。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) is_number

XuAPI
pub fn (d Doc) is_number(n int) bool

用途

`Doc` 上的方法:判断是否 number。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) is_bool

XuAPI
pub fn (d Doc) is_bool(n int) bool

用途

`Doc` 上的方法:判断是否 bool。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) as_bool

XuAPI
pub fn (d Doc) as_bool(n int) bool

用途

`Doc` 上的方法:asbool。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) as_string

XuAPI
pub fn (d Doc) as_string(n int) string

用途

`Doc` 上的方法:as字符串。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

string — 结果字符串

(Doc) as_null

XuAPI
pub fn (d Doc) as_null(n int) int

用途

`Doc` 上的方法:asnull。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(Doc) as_int

XuAPI
pub fn (d Doc) as_int(n int) int

用途

`Doc` 上的方法:asint。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(Doc) as_f64

XuAPI
pub fn (d Doc) as_f64(n int) f64

用途

`Doc` 上的方法:asf64。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

f64 — 该类型的值

(Doc) is_null

XuAPI
pub fn (d Doc) is_null(n int) bool

用途

`Doc` 上的方法:判断是否 null。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

bool — 是否成立

(Doc) text

XuAPI
pub fn (d Doc) text(n int) string

用途

`Doc` 上的方法:返回当前文本。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

string — 结果字符串

(Doc) key

XuAPI
pub fn (d Doc) key(n int) string

用途

`Doc` 上的方法:键。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

string — 结果字符串

(Doc) count

XuAPI
pub fn (d Doc) count(n int) int

用途

`Doc` 上的方法:统计非重叠出现次数。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(Doc) at

XuAPI
pub fn (d Doc) at(n int, i int) int

用途

在 `Doc` 上调用 `at`。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)
i int
下标或整数(int)

返回

int — 该类型的值

(Doc) has

XuAPI
pub fn (d Doc) has(n int, key string) bool

用途

`Doc` 上的方法:是否具有。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)
key string
键(string)

返回

bool — 是否成立

(Doc) dict_keys

XuAPI
pub fn (d Doc) dict_keys(n int) []string

用途

`Doc` 上的方法:dictkeys。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

[]string — 切片结果

(Doc) get

XuAPI
pub fn (d Doc) get(n int, key string) int

用途

在 `Doc` 上调用 `get`。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)
key string
键(string)

返回

int — 该类型的值

(Doc) number_int

XuAPI
pub fn (d Doc) number_int(n int) int

用途

`Doc` 上的方法:numberint。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

int — 该类型的值

(Doc) number_f64

XuAPI
pub fn (d Doc) number_f64(n int) f64

用途

`Doc` 上的方法:numberf64。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

f64 — 该类型的值

parse

XuAPI
pub fn parse(src &string) Doc

用途

解析输入。

参数

src &string
源数据(借用,调用方仍持有;类型 &string)

返回

Doc — 该类型的值

escape

XuAPI
pub fn escape(s &string) string

用途

转义。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

quote

XuAPI
pub fn quote(s &string) string

用途

加上引号并转义。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

unquote

XuAPI
pub fn unquote(s &string) string

用途

去掉引号并还原转义。失败时 throw。

参数

s &string
源字符串(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

(Doc) to_json

XuAPI
pub fn (d Doc) to_json() string

用途

`Doc` 上的方法:转换为 json。

参数

d Doc
接收者 Doc(值接收者)

返回

string — 结果字符串

valid

XuAPI
pub fn valid(src &string) bool

用途

是否合法。

参数

src &string
源数据(借用,调用方仍持有;类型 &string)

返回

bool — 是否成立

compact

XuAPI
pub fn compact(src &string) string

用途

压成一行。失败时 throw。

参数

src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

indent

XuAPI
pub fn indent(src &string, prefix &string, gap &string) string

用途

缩进。失败时 throw。

参数

src &string
源数据(借用,调用方仍持有;类型 &string)
prefix &string
前缀(借用,调用方仍持有;类型 &string)
gap &string
gap(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

html_escape

XuAPI
pub fn html_escape(src &string) string

用途

HTML转义。

参数

src &string
源数据(借用,调用方仍持有;类型 &string)

返回

string — 结果字符串

(Doc) encode

XuAPI
pub fn (d Doc) encode(n int) string

用途

`Doc` 上的方法:编码。失败时 throw。

参数

d Doc
接收者 Doc(值接收者)
n int
数量、长度或上限(int)

返回

string — 结果字符串