Aracılığıyla paylaş


STRINGTOARRAY - Cosmos DB'de sorgu dili (Azure ve Doku'da)

işlevi bir STRINGTOARRAY dize ifadesini diziye dönüştürür.

Diziye dönüştürülmüş bir dize ifadesi döndüren bir Azure Cosmos DB sistem işlevi.

Sözdizimi

STRINGTOARRAY(<string_expr>)

Arguments

Description
string_expr Dize ifadesi.

Dönüş türleri

Bir dizi döndürür.

Örnekler

Bu bölüm, bu sorgu dili yapısının nasıl kullanılacağına örnekler içerir.

Dizeyi diziye dönüştürme

Bu örnekte işlev, STRINGTOARRAY çeşitli dize değerlerini diziler halinde ayrıştırmak için kullanılır.

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" ]
    ]
  }
]

Açıklamalar

  • Bu işlev dizini kullanmaz.