次の方法で共有


STRINGTOARRAY - Cosmos DB のクエリ言語 (Azure と Fabric)

STRINGTOARRAY関数は、文字列式を配列に変換します。

配列に変換された文字列式を返す Azure Cosmos DB for NoSQL システム関数。

構文

STRINGTOARRAY(<string_expr>)

論争

Description
string_expr 文字列式。

戻り値の型

配列を返します。

例示

このセクションでは、このクエリ言語コンストラクトを使用する方法の例を示します。

文字列を配列に変換する

この例では、 STRINGTOARRAY 関数を使用して、さまざまな文字列値を配列に解析します。

SELECT VALUE {
  parseEmptyArray: STRINGTOARRAY("[]"),
  parseArray: STRINGTOARRAY('[ "coats", "gloves", "hats" ]'),
  complexArray: STRINGTOARRAY('[ { "types": [ "coats", "gloves" ] }, [ "hats" ], 76, false, null ]'),
  nestedArray: STRINGTOARRAY('[ [ "coats", "gloves" ], [ "hats" ] ]'),
  invalidArray: STRINGTOARRAY("[ 'coats', 'gloves', 'hats' ]"),
  parseUndefined: STRINGTOARRAY(undefined),
  parseNull: STRINGTOARRAY(null)
}
[
  {
    "parseEmptyArray": [],
    "parseArray": [ "coats", "gloves", "hats" ],
    "complexArray": [
      {
        "types": [ "coats", "gloves" ]
      },
      [ "hats" ],
      76,
      false,
      null
    ],
    "nestedArray": [
      [ "coats", "gloves" ],
      [ "hats" ]
    ]
  }
]

注釈

  • この関数では、インデックスは使用されません。