Turbowarp拡張機能: JSON & Array Utils Turbowarp Extension: JSON & Array Utils

JSONと配列を扱うための拡張機能 An extension for handling JSON and Arrays

概要 Overview

本拡張機能は、ScratchやTurbowarpで複雑なデータを容易に扱うためのツールセットを提供します。APIから取得したデータ(JSON)の解析や、ゲームのステージデータの配列管理など、従来煩雑であったデータ操作をブロックベースで直感的に行うことを可能にします。 This extension provides a toolset for easily handling complex data in Scratch and Turbowarp. It enables intuitive, block-based data manipulation, such as parsing data from APIs (JSON) or managing game stage data with arrays, which were traditionally cumbersome tasks.


共通仕様 General Specifications

本拡張機能を使用する上での共通の仕様です。 These are the general rules for using this extension.


JSON系統ブロック JSON Blocks

JSONオブジェクトを操作するためのブロック群です。 These are blocks for manipulating JSON objects.

通常ブロック Standard Blocks

JSON変数 [jsonVarID v] を空にする

指定したJSON変数を空のJSON {} にします。Clears the specified JSON variable to an empty JSON {}.

JSON変数 [jsonVarID v][json] にする

指定したJSON変数に、新しいJSONデータをセットします。Sets the specified JSON variable to the new JSON data.

※ 指定された値がJSONとして無効な場合は、空のJSON {} がセットされます。* If the provided value is not valid JSON, an empty JSON {} will be set.

JSON変数 [jsonVarID v] を配列変数 [arrayVarID v][index] 番目にする

配列内に含まれるJSONオブジェクトを、指定のJSON変数にセットします。Sets a JSON variable to a JSON object from within an array.

JSON変数 [jsonVarID v][JSONPath][value] にする

JSONPathで指定した場所の値を、指定の値で上書きします。パスが存在しない場合は新規に作成されます。Sets or overwrites the value at the specified JSONPath. New keys/paths will be created if they don't exist.

JSON変数 [jsonVarID v][JSONPath][number] ずつ変える

JSONPathで指定した場所の値を、指定の数値だけ増減させます。Changes the value at the specified JSONPath by the given number.

※ 元の値が数値であれば加算します。数値でない場合は、元の値を指定のnumberで上書きします。* If the original value is a number, it adds to it. Otherwise, it overwrites the value with the given number.

JSON変数 [jsonVarID v][JSONPath] の値を削除

JSONPathで指定したキーとその値をJSONから削除します。Deletes the key and its value at the specified JSONPath.

JSON変数 [jsonVarID v] にJSON [json] を統合

既存のJSONに、別のJSONオブジェクトをマージします。キーが重複する場合、後から統合したJSONの値で上書きされます。Merges another JSON object into the existing one. If keys conflict, the new JSON's values will be used.

Reporter (値を返す) Reporter (Value-returning)

JSON変数 [jsonVarID v]

JSON変数の内容を文字列として出力します。Returns the content of the JSON variable as a string.

JSON変数 [jsonVarID v][JSONPath] の値

JSONPathで指定した場所の値を取得します。Gets the value at the specified JSONPath.

JSON変数 [jsonVarID v] の長さ

JSONの第一階層にあるキーの総数を返します。Returns the number of top-level keys in the JSON.

JSON変数 [jsonVarID v] の全てのキー

JSONの第一階層にある全てのキーを配列として返します。Returns all top-level keys as an array.

JSON変数 [jsonVarID v] の全ての値

JSONの第一階層にある全ての値を配列として返します。Returns all top-level values as an array.

Reporter (真偽値を返す) Reporter (Boolean-returning)

<JSON変数 [jsonVarID v] が空>

JSON変数が {} であるか否かを判定します。Checks if the JSON variable is empty ({}).

<JSON変数 [jsonVarID v] がキー [JSONPath] を含む>

指定したJSONPathのキーが存在するか否かを判定します。Checks if a key exists at the specified JSONPath.

<JSON変数 [jsonVarID v][jsonVarID2 v] が等しい>

二つのJSON変数の内容が等価であるか否かを判定します。Checks if two JSON variables are deeply equal.

※ キーの順序は考慮されません。{"a":0,"b":1}{"b":1,"a":0} は等価とみなされます。* Key order is ignored. {"a":0,"b":1} and {"b":1,"a":0} are considered equal.


Array系統ブロック Array Blocks

配列(リスト)を操作するためのブロック群です。 These are blocks for manipulating arrays (lists).

通常ブロック Standard Blocks

配列変数 [arrayVarID v] を空にする

指定した配列変数を空の配列 [] にします。Clears the specified array variable to an empty array [].

配列変数 [arrayVarID v][array] にする

指定した配列変数に、新しい配列データをセットします。Sets the specified array variable to the new array data.

配列変数 [arrayVarID v] をJSON変数 [jsonVarID v][JSONPath] にする

JSON内の配列を、指定の配列変数にセットします。Sets an array variable to an array from within a JSON.

※ 指定された値が配列でない場合は、空の配列 [] がセットされます。* If the value at the path is not an array, an empty array [] will be set.

配列変数 [arrayVarID v][value] を追加

配列の末尾に新しい値を追加します。Adds a new value to the end of the array.

配列変数 [arrayVarID v][index] 番目を [value] で置き換える

指定したインデックスの値を、新しい値で上書きします。Replaces the value at the specified index with a new value.

配列変数 [arrayVarID v][index] 番目を [number] ずつ変える

指定したインデックスの値を、指定の数値だけ増減させます。Changes the value at the specified index by the given number.

※ 元の値が数値であれば加算します。数値でない場合は、元の値を指定のnumberで上書きします。* If the original value is a number, it adds to it. Otherwise, it overwrites the value with the given number.

配列変数 [arrayVarID v][index] 番目に [value] を挿入する

指定したインデックスに新しい値を挿入します。既存の要素は後方へシフトします。Inserts a new value at the specified index, shifting existing elements back.

配列変数 [arrayVarID v][index] 番目を削除する

指定したインデックスの値を削除します。Deletes the value at the specified index.

配列変数 [arrayVarID v][index] 番目の [value] を削除する

指定の値が配列内に複数存在する場合、そのうちN番目の要素のみを削除します。If the specified value exists multiple times, this removes only the Nth occurrence.

例: ["a",1,"a",1,1] から「2番目の1」を削除すると ["a","a",1,1] となります。Example: Removing the "2nd occurrence of 1" from ["a",1,"a",1,1] results in ["a","a",1,1].

配列変数 [arrayVarID v] の全ての [value] を削除する

配列内から、指定の値と一致する全ての要素を削除します。Removes all occurrences of the specified value from the array.

配列変数 [arrayVarID v] をテキスト [text] から作成

テキストを1文字ずつに分解して配列を生成します。例: "abcd" → ["a","b","c","d"]Creates an array by splitting a text into individual characters. E.g., "abcd" → ["a","b","c","d"]

配列変数 [arrayVarID v] をテキスト [text] と区切り文字 [split] から作成

指定の区切り文字でテキストを分割し、配列を生成します。例: "a,b,c" と "," → ["a","b","c"]Creates an array by splitting a text by a delimiter. E.g., "a,b,c" with "," → ["a","b","c"]

配列変数 [arrayVarID v] の順番を逆にする

配列の要素の順序を反転させます。Reverses the order of the elements in the array.

配列変数 [arrayVarID v] をランダムに並べ替える

配列の要素をランダムにシャッフルします。Randomly shuffles the elements of the array.

配列変数 [arrayVarID v] を数字の [昇順 v] に並べ替える

配列内の数値を昇順または降順に並べ替えます。Sorts the numbers in the array in ascending or descending order.

※ 数値以外の要素は、元の順序を維持したまま配列の後方へ移動します。* Non-numeric elements are moved to the end of the array, preserving their original order.

配列変数 [arrayVarID v] をアルファベットの昇順に並べ替える

配列内の文字列をアルファベット順(辞書順)に並べ替えます。Sorts the strings in the array alphabetically (lexicographically).

※ 文字列以外の要素は、元の順序を維持したまま配列の後方へ移動します。* Non-string elements are moved to the end of the array, preserving their original order.

配列変数 [arrayVarID v] を深さ [depth] で平らにする

入れ子構造の配列をフラットにします。例: [[1],2,[3,4]] を深さ1で平らにすると [1,2,3,4] となります。Flattens a nested array to a specified depth. E.g., flattening [[1],2,[3,4]] by depth 1 results in [1,2,3,4].

配列変数 [arrayVarID v] に配列 [array] を繋げる

既存の配列に、別の配列を連結します。Concatenates another array to the end of the existing array.

配列変数 [arrayVarID v] に配列変数 [arrayVarID2 v] を繋げる

配列変数同士を連結します。Concatenates another array variable to the existing one.

配列変数 [arrayVarID v][repeat] 回繰り返す

配列の内容を指定回数繰り返し、一つの配列として結合します。例: [0,1] を3回 → [0,1,0,1,0,1]Creates a new array by repeating the contents of the array a specified number of times. E.g., repeating [0,1] 3 times → [0,1,0,1,0,1]

配列変数 [arrayVarID v][index] まで埋める

配列の要素数が指定の長さに満たない場合、空白で要素を補完します。If the array length is less than the specified index, it pads the array with empty strings up to that length.

配列変数 [arrayVarID v] の重複を削除する

配列内から重複する要素を削除し、各要素が一意になるようにします(最初に出現した要素が保持されます)。Removes duplicate elements from the array, keeping only the first occurrence of each element.

配列変数 [arrayVarID v] に正規表現 [regex] でフィルタ

正規表現にマッチした要素のみを抽出し、新しい配列を生成します。Filters the array, keeping only the elements that match the regular expression.

配列変数 [arrayVarID v][number1] 以上 [number2] 以下に収める

配列内の各数値が指定の範囲内に収まるように値を調整します。範囲外の値は、最も近い境界値に置き換えられます。Clamps each number in the array to be within the given range [number1, number2]. Values outside the range are replaced by the nearest boundary value.

配列変数 [arrayVarID v] の最小値を [min] 、最大値を [max] で正規化

配列内の数値の分布が、指定した最小値(min)と最大値(max)の範囲に収まるように線形変換を行います。Normalizes the numbers in the array to fit within a new range [min, max] using linear transformation.

配列変数 [arrayVarID v] [+ v] [number]

配列内の全ての数値に対し、四則演算(+, -, *, /, ^)を一括で実行します。Performs an arithmetic operation (+, -, *, /, ^) on every number in the array.

※ ゼロ除算の結果は Infinity となります。* Division by zero results in Infinity.

Reporter (値を返す) Reporter (Value-returning)

配列変数 [arrayVarID v]

配列変数の内容を文字列として出力します。Returns the content of the array variable as a string.

配列変数 [arrayVarID v] の長さ

配列の要素数を返します。Returns the number of elements in the array.

配列変数 [arrayVarID v][index] 番目

指定したインデックスの値を返します。Returns the value at the specified index.

配列変数 [arrayVarID v] のランダムな要素

配列内からランダムに選択された一つの要素を返します。Returns a random element from the array.

配列変数 [arrayVarID v] の最初の [value] の場所

指定の値が配列内で最初に現れるインデックスを返します。Returns the index of the first occurrence of the specified value.

配列変数 [arrayVarID v][index] 番目の [value] の場所

指定の値が配列内でN番目に現れるインデックスを返します。例: [0,1,1,2] の「2番目の1」の場所は 3Returns the index of the Nth occurrence of the specified value. E.g., the index of the "2nd 1" in [0,1,1,2] is 3.

配列変数 [arrayVarID v][index1] 番目から [index2] 番目

配列の一部を抽出し、新しい配列として返します。Returns a slice of the array between two indices as a new array.

配列変数 [arrayVarID v] からの全てのキー [key] の値

JSONオブジェクトの配列から、指定したキーの値を全て抽出し、新しい配列を生成します。例: [{"id":12},{"id":24}] から "id" の値を取得すると [12,24]From an array of JSON objects, extracts all values for a specific key into a new array. E.g., getting key "id" from [{"id":12},{"id":24}] returns [12,24].

配列変数 [arrayVarID v] を区切り文字 [split] で繋げる

配列の各要素を指定の区切り文字で連結し、一つの文字列を生成します。例: ["a","b","c"] を "," で連結すると "a,b,c"Joins the elements of an array into a single string using a delimiter. E.g., joining ["a","b","c"] with "," returns "a,b,c".

配列変数 [arrayVarID v][最小値 v]

配列内の数値から、最小値、最大値、合計、平均、中央値、最頻値、分散、標準偏差を算出します。Calculates a statistical value from the numbers in the array: min, max, sum, average, median, mode, variance, or standard deviation.

Reporter (真偽値を返す) Reporter (Boolean-returning)

<配列変数 [arrayVarID v] は空>

配列変数が [] であるか否かを判定します。Checks if the array variable is empty ([]).

<配列変数 [arrayVarID v][value] を含む>

指定の値が配列内に存在するか否かを判定します。Checks if the array contains the specified value.

<配列変数 [arrayVarID v][arrayVarID2 v] が等しい>

二つの配列変数の内容と順序が完全に一致するか否かを判定します。Checks if two arrays are identical in content and order.


その他 Others

拡張機能全体に関連するブロックです。 Blocks related to the extension as a whole.

Reporter

全てのJSON変数

プロジェクト内に存在する全てのJSON変数を、変数名をキー、内容を値とした単一のJSONオブジェクトとして出力します。Exports all JSON variables in the project as a single JSON object, where keys are variable names.

全ての配列変数

プロジェクト内に存在する全ての配列変数を、変数名をキー、内容を値とした単一のJSONオブジェクトとして出力します。Exports all array variables in the project as a single JSON object, where keys are variable names.