Use two single quotes instead of double quotes in JPath expressions
JPath filter expressions in AL use string comparisons to match JSON values. Developers familiar with standard JSON or JPath syntax naturally reach for double quotes to delimit string values inside the path — "activation_status", "John". In AL, the JPath evaluator expects single quotes around string values inside filter expressions.
Ensure that the selected expression contains ’ (single quotation mark) and not " (double quotation mark) to decorate the string value.
— JsonToken.SelectToken(Text, var JsonToken) Method on Microsoft Learn
When a JPath expression contains double quotes, SelectToken and SelectTokens fail silently — the method returns false and the result token remains empty, with no runtime error to indicate what went wrong. Replace double quotes with two single quotes (''), which AL interprets as a literal single quote character.
Example
procedure GetAttributeValue(ApiResponse: JsonToken)
var
Result: JsonToken;
begin
ApiResponse.SelectToken('$.custom_attributes[?(@.attribute_code == "activation_status")].value', Result); // Use two single quotes instead of double quotes in JPath expressions [PC0014]
end;Replace the double quotes with two single quotes:
procedure GetAttributeValue(ApiResponse: JsonToken)
var
Result: JsonToken;
begin
ApiResponse.SelectToken('$.custom_attributes[?(@.attribute_code == ''activation_status'')].value', Result);
end;When the diagnostic is reported
- A string literal passed as the
Pathparameter toSelectTokenorSelectTokenscontains a double quote (") character. - The rule applies to calls on
JsonToken,JsonObject, andJsonArray.
See also
- JsonToken.SelectTokens(Text, var List of [JsonToken]) Method on Microsoft Learn