API Gateway: JSON Path Expression with tab characters

book

Article ID: 131927

calendar_today

Updated On:

Products

STARTER PACK-7 CA Rapid App Security 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:
Component: APIESM

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.