定義
ないなら作る
// JSON.d.ts
export type JSON = JsonPrimitive | JsonArray | JsonObject;
export type JsonObject = {
[key: string]: JSON;
};
export type JsonArray = JsonPrimitive[] | JsonObject[] | JsonArray[];
export type JsonPrimitive = string | number | boolean | null;
Usage
import type { JSON } from "./JSON.d"
const json: JSON = {
"文字": "abc",
"数値": 123,
"真偽": false,
"NULL": null,
"配列": [
"a", "b", "c",
1, 2, 3,
true, false,
["a", "b", "c"],
[1, 2, 3],
[true, false],
[null],
{
"プロパティ": "値",
"配列": [
// ... (略) ...
]
}
// ... (略) ...
],
"物体": {
"プロパティ": "値",
"配列": [
// ... (略) ...
]
"プロパティ": {
// ... (略) ...
}
}
}
了