{"title":"JsonArray.SelectToken(Text, var JsonToken) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/jsonarray/jsonarray-selecttoken-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/jsonarray/jsonarray-selecttoken-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/jsonarray/jsonarray-selecttoken-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Selects a JsonToken using a JPath expression.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"JsonArray.SelectToken(Text, var JsonToken) Method","slug":"jsonarrayselecttokentext-var-jsontoken-method","at":0,"chars":2081},{"level":2,"title":"Syntax","slug":"syntax","at":158,"chars":87},{"level":2,"title":"Parameters","slug":"parameters","at":245,"chars":288},{"level":2,"title":"Return Value","slug":"return-value","at":533,"chars":234},{"level":2,"title":"Remarks","slug":"remarks","at":767,"chars":105},{"level":2,"title":"Example","slug":"example","at":872,"chars":1072},{"level":2,"title":"Related information","slug":"related-information","at":1944,"chars":137}],"text":"# JsonArray.SelectToken(Text, var JsonToken) Method\n> Version: _Available or changed with runtime version 1.0._\nSelects a JsonToken using a JPath expression.\n## Syntax\n```al\n[Ok := ]  JsonArray.SelectToken(Path: Text, var Result: JsonToken)\n```\n## Parameters\nJsonArray\nType: jsonarray-data-type\nAn instance of the jsonarray-data-type data type.\nPath\nType: ../text/text-data-type\nA valid JPath expression.\nResult\nType: ../jsontoken/jsontoken-data-type\nA JsonToken variable that will contain the result if the operation is successful.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the read was successful; otherwise, false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\nThe operation will fail if more or less than 1 tokens are the result of evaluating the JPath.\n## Example\nThe following example shows how to select a value from a complex JSON Object. We build up a select expression in the query variable, we select the token corresponding to the salary of the employee with the given employeeId, and finally, we convert the token to a Decimal value.\nWe assume that the company token contains JSON data similar to the one below.\n```json\n{ \"company\": {\n    \"employees\": [\n      { \"id\": \"Marcy\",\n        \"salary\": 8.95\n      },\n      { \"id\": \"John\",\n        \"salary\": 7\n      },\n      { \"id\": \"Diana\",\n        \"salary\": 10.95\n      }\n    ]\n  }\n}\n```\n```al\nlocal procedure SelectEmployeeSalary(companyData : JsonToken; employeeId : Text) salary : Decimal\n\nvar\n    query : Text;\n    salaryToken : JsonToken;\nbegin\n    query := '$.company.employees[?(@.id=='''+employeeId+''')].salary';\n    companyData.SelectToken(query, salaryToken);\n\n    salary := salaryToken.AsValue().AsDecimal();\nend;\n```\n> NOTE\n> Ensure that the selected expression contains ' (single quotation mark) and not \" (double quotation mark) to decorate the string value.\n## Related information\njsonarray-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}