API Gateway: JSON Path Expression with tab characters
search cancel

API Gateway: JSON Path Expression with tab characters

book

Article ID: 131927

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

When using the JSON Path expression against a value containing a literal TAB it will fail resulting in an error similar to the below:

Source JSON
{
 "name":"value    here"
}

Error
Expected EOF but found trailing tokens.: [Source: {
 "name":"value    here"
}; line: 2, column: 16]

Environment

Release: All Supported Gateway
Component: Gateway

Resolution

According to the ECMA JSON Data Interchange Syntax TAB characters need to be properly escaped when used,

\t represents the character tabulation character (U+0009).

To resolve this you would either
1) Change the source data to include properly escaped JSON

{
 "name":"value\there"
}

2) Uses a RegEx assertion against the JSON replacing the TAB with a single space or escape sequence.

Using the expression
\t
to be replaced with
\\t

The double backslash is required for the replacement so it is not treated as a RegEx escape sequence.