title | titleSuffix | description | author | ms.author | ms.reviewer | ms.service | ms.subservice | ms.topic | ms.devlang | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|
StringToObject |
Azure Cosmos DB for NoSQL |
An Azure Cosmos DB for NoSQL system function that returns a string expression converted to an object. |
jcodella |
jacodel |
sidandrews |
cosmos-db |
nosql |
reference |
nosql |
02/27/2024 |
query-reference |
[!INCLUDENoSQL]
Converts a string expression to an object.
StringToObject(<string_expr>)
Description | |
---|---|
string_expr |
A string expression. |
Returns an object.
The following example illustrates how this function works with various inputs.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/stringtoobject/query.sql" highlight="2-7":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/stringtoobject/result.json":::
- 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.