Skip to content

Commit 973031c

Browse files
docs: update documents for v1.2.0
1 parent 381550d commit 973031c

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

docs/en/references/interface/aison.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,29 @@ More strictly:
2323

2424
## JavaScript API
2525

26-
The `@syuilo/aiscript` package includes a built-in function for parsing AiSON. You can use `AiSON.parse` to convert an AiSON string directly into a JavaScript value.
26+
The `@syuilo/aiscript` package includes a built-in function for parsing AiSON.
2727

28-
:::tip
29-
Currently, only parsing from AiSON to JavaScript is supported. A function to serialize a JavaScript object into an AiSON string (`AiSON.stringify`) has not yet been implemented.
30-
:::
28+
You can use `AiSON.parse` to convert an AiSON string directly into a JavaScript value. Syntax errors will throw an `errors.AiScriptSyntaxError`.
3129

3230
```ts
3331
import { AiSON } from '@syuilo/aiscript';
3432

3533
const data = AiSON.parse('{ key: "value" }');
3634
```
35+
36+
You can use `AiSON.stringify` to convert a JavaScript value into an AiSON string. The first argument is the value to convert, and the **third** argument specifies the indentation width. The second argument is unused and exists for compatibility with `JSON.stringify` (replacer functions are not supported).
37+
38+
```ts
39+
import { AiSON } from '@syuilo/aiscript';
40+
41+
const data = { key: "value" };
42+
43+
// Generate AiSON string without indentation
44+
const str1 = AiSON.stringify(data);
45+
46+
// Generate AiSON string with an indentation width of 2
47+
const str2 = AiSON.stringify(data, null, 2);
48+
49+
// Generate AiSON string indented with tabs
50+
const str3 = AiSON.stringify(data, null, '\t');
51+
```

docs/en/references/std.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The array will be filled with _initial_ if given, otherwise with `null`.
175175
Returns an array of object keys, values, and key/value pairs.
176176

177177
#### @Obj:from_kvs(_kvs_: arr): obj;
178-
Creates an object from key/value pairs. (Available from v1.1.2 or later)
178+
Creates an object from key/value pairs. (Available from v1.2.0 or later)
179179

180180
#### @Obj:get<T>(_v_: obj<T>, _key_: str): T
181181

docs/ja/references/interface/aison.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,29 @@ JSONに比べ、オブジェクトのkeyに`"`(ダブルクォーテーショ
2222

2323
## JavaScript API
2424

25-
AiSONをパースするための関数は`@syuilo/aiscript`に内包されています。`AiSON.parse`でAiSONの文字列からJavaScript Valueへの変換が可能です。
25+
AiSONをパースするための関数は`@syuilo/aiscript`に内包されています。
2626

27-
:::tip
28-
現時点ではパースのみ可能です。AiSONへ変換する(`AiSON.stringify`)は実装されていません。
29-
:::
27+
`AiSON.parse`でAiSONの文字列からJavaScript Valueへの変換が可能です。シンタックスエラー時は `errors.AiScriptSyntaxError` がスローされます。
3028

3129
```ts
3230
import { AiSON } from '@syuilo/aiscript';
3331

3432
const data = AiSON.parse('{key: "value"}');
3533
```
34+
35+
AiScript v1.2.0 以降では、`AiSON.stringify`でJavaScript ValueからAiSONの文字列への変換が可能です。第一引数に変換したい値を、**第三引数に**インデント幅を指定します。第二引数は`JSON.stringify`とインターフェイスの互換性を保つために未使用となっています(リプレイサー関数はサポートされていません)。
36+
37+
```ts
38+
import { AiSON } from '@syuilo/aiscript';
39+
40+
const data = { key: "value" };
41+
42+
// インデントなしで整形されたAiSON文字列を生成
43+
const str1 = AiSON.stringify(data);
44+
45+
// インデント幅2で整形されたAiSON文字列を生成
46+
const str2 = AiSON.stringify(data, null, 2);
47+
48+
// タブでインデントされたAiSON文字列を生成
49+
const str3 = AiSON.stringify(data, null, '\t');
50+
```

docs/ja/references/std.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ encoded_text をエンコードされたURI構成要素としてデコードし
177177
オブジェクトのキー、値、キーと値の組を配列にして返します。
178178

179179
#### @Obj:from_kvs(_kvs_: arr): obj;
180-
キーと値の組の配列からオブジェクトを作成して返します。(v1.1.2以降で使用可能
180+
キーと値の組の配列からオブジェクトを作成して返します。(v1.2.0以降で使用可能
181181

182182
#### @Obj:get<T>(_v_: obj<T>, _key_: str): T
183183

0 commit comments

Comments
 (0)