แก้ไข

แชร์ผ่าน


StringToObject (NoSQL query)

APPLIES TO: NoSQL

Converts a string expression to an object.

Syntax

StringToObject(<string_expr>)  

Arguments

Description
string_expr A string expression.

Return types

Returns an object.

Examples

The following example illustrates how this function works with various inputs.

SELECT VALUE {
    parseEmptyObject: StringToObject("{}"),
    parseObjectWithProperty: StringToObject('{"isAvailable": true}'),
    parseObjectNested: StringToObject('{"division": {"name": "Sales"}}'),
    parseObjectInvalidJson: StringToObject("{'price': 27.55}"),
    parseUndefined: StringToNumber(undefined),
    parseNull: StringToNumber(null)
}
[
  {
    "parseEmptyObject": {},
    "parseObjectWithProperty": {
      "isAvailable": true
    },
    "parseObjectNested": {
      "division": {
        "name": "Sales"
      }
    }
  }
]

Remarks

  • This function doesn't use the index.
  • If the expression can't be converted, the function returns undefined.
  • Nested string values must be written with double quotes to be valid.

Note

For more information on the JSON format, see https://json.org.