Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/reference/model/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -28,7 +28,7 @@ Deserialize `value` (a string instance containing a JSON document) to a KCL obje

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -40,3 +40,11 @@ dump_to_file(
```

Serialize a KCL object `data` to a JSON formatted str and write it into the file `filename`.

## validate

```python
validate(value: str) -> bool
```

Validate whether the given string is a valid JSON.
31 changes: 29 additions & 2 deletions docs/reference/model/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 300

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -19,15 +19,34 @@ encode(

Serialize a KCL object `data` to a YAML formatted str.

## encode_all

```python
encode(
data: [any],
sort_keys: bool = False,
ignore_private: bool = False,
ignore_none: bool = False
) -> str
```

Serialize a sequence of KCL objects into a YAML stream str.

## decode

`decode(value: str) -> any`

Deserialize `value` (a string instance containing a YAML document) to a KCL object.

## decode_all

`decode_all(value: str) -> [any]`

Parse all YAML documents in a stream and produce corresponding KCL objects.

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -37,3 +56,11 @@ dump_to_file(
```

Serialize a KCL object `data` to a YAML formatted str and write it into the file `filename`.

## validate

```python
validate(value: str) -> bool
```

Validate whether the given string is a valid YAML or YAML stream document.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -28,7 +28,7 @@ encode(

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -40,3 +40,11 @@ dump_to_file(
```

将 KCL 对象 `data` 序列化为 JSON 格式的字符串,并将其写入文件 `filename` 中。

## validate

```python
validate(value: str) -> bool
```

验证给定的字符串是否是一个合法的 JSON 字符串。
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 300

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -19,15 +19,34 @@ encode(

将 KCL 对象 `data` 序列化为 YAML 格式的字符串。

## encode_all

```python
encode(
data: [any],
sort_keys: bool = False,
ignore_private: bool = False,
ignore_none: bool = False
) -> str
```

将 KCL 对象列表 `data` 序列化为包含 `---` 分隔符的 YAML Stream 格式的字符串。

## decode

`decode(value: str) -> any`

反序列化 `value`(一个包含 YAML 格式文档的字符串实例)为一个 KCL 对象。

## decode_all

`decode_all(value: str) -> [any]`

反序列化 `value`(一个包含 `---` 分隔符的 YAML Stream 格式文档的字符串实例)为一个 KCL 对象列表。

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -38,3 +57,11 @@ dump_to_file(
```

将 KCL 对象 `data` 序列化为 YAML 格式的字符串,并将其写入文件 `filename` 中。

## validate

```python
validate(value: str) -> bool
```

验证给定的字符串是否是一个合法的 YAML 或者 YAML Stream 格式的字符串。
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -28,7 +28,7 @@ encode(

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -40,3 +40,11 @@ dump_to_file(
```

将 KCL 对象 `data` 序列化为 JSON 格式的字符串,并将其写入文件 `filename` 中。

## validate

```python
validate(value: str) -> bool
```

验证给定的字符串是否是一个合法的 JSON 字符串。
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 300

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -19,15 +19,34 @@ encode(

将 KCL 对象 `data` 序列化为 YAML 格式的字符串。

## encode_all

```python
encode(
data: [any],
sort_keys: bool = False,
ignore_private: bool = False,
ignore_none: bool = False
) -> str
```

将 KCL 对象列表 `data` 序列化为包含 `---` 分隔符的 YAML Stream 格式的字符串。

## decode

`decode(value: str) -> any`

反序列化 `value`(一个包含 YAML 格式文档的字符串实例)为一个 KCL 对象。

## decode_all

`decode_all(value: str) -> [any]`

反序列化 `value`(一个包含 `---` 分隔符的 YAML Stream 格式文档的字符串实例)为一个 KCL 对象列表。

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -38,3 +57,11 @@ dump_to_file(
```

将 KCL 对象 `data` 序列化为 YAML 格式的字符串,并将其写入文件 `filename` 中。

## validate

```python
validate(value: str) -> bool
```

验证给定的字符串是否是一个合法的 YAML 或者 YAML Stream 格式的字符串。
12 changes: 10 additions & 2 deletions versioned_docs/version-0.7.0/reference/model/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 100

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -28,7 +28,7 @@ Deserialize `value` (a string instance containing a JSON document) to a KCL obje

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -40,3 +40,11 @@ dump_to_file(
```

Serialize a KCL object `data` to a JSON formatted str and write it into the file `filename`.

## validate

```python
validate(value: str) -> bool
```

Validate whether the given string is a valid JSON.
31 changes: 29 additions & 2 deletions versioned_docs/version-0.7.0/reference/model/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 300

## encode

```
```python
encode(
data: any,
sort_keys: bool = False,
Expand All @@ -19,15 +19,34 @@ encode(

Serialize a KCL object `data` to a YAML formatted str.

## encode_all

```python
encode(
data: [any],
sort_keys: bool = False,
ignore_private: bool = False,
ignore_none: bool = False
) -> str
```

Serialize a sequence of KCL objects into a YAML stream str.

## decode

`decode(value: str) -> any`

Deserialize `value` (a string instance containing a YAML document) to a KCL object.

## decode_all

`decode_all(value: str) -> [any]`

Parse all YAML documents in a stream and produce corresponding KCL objects.

## dump_to_file

```
```python
dump_to_file(
data: any,
filename: str,
Expand All @@ -37,3 +56,11 @@ dump_to_file(
```

Serialize a KCL object `data` to a YAML formatted str and write it into the file `filename`.

## validate

```python
validate(value: str) -> bool
```

Validate whether the given string is a valid YAML or YAML stream document.