Embedded quote formats for tuples sent using the TIBCO Streaming Client API
book
Article ID: KB0074466
calendar_today
Updated On:
Description
Submitting a JSON string over the StreamBase Client API with escaped quotes like this fails:
echo connect,https://devserver:10000/ShippingAPI/ValidateContainer,"[{\"SystemID\":\"ARCS\",\"Timestamp\":\"2020-01-01 13:01:02.147\",\"CrateNo\":\"GHK98765\",\"INo\":\"1212121212\"},application/json,FALSE]",testflow | epadmin --servicename=A.http enqueue stream --path=main.Control
The error is "
Warning = Quoted literal not followed by delimiter".
This command uses the TIBCO Streaming Client API to send a tuple as a comma-separated-values (CSV) string echoed into STDIN of the '
epadmin enqueue stream' command.
Resolution
The 'epadmin enqueue stream' command cannot parse backslash-escaped quotes. Parsing text into a tuple is not evaluated as an expression and does not follow Expression Language syntax, but instead follows CSV quoting syntax. Within a CSV record, the main delimiter is a comma (,). Single string values may contain a comma as long as the value also has a leading and terminating double quote.
Quotes are handled according to these rules:
- Two double quotes surrounding a single value are treated as delimiters.
- Repeated adjacent double quotes found in the string force the string to be interpreted literally.
- A single quote (') is interpreted literally (it is not a delimiter).
The preferred solution is to use inner single-quotes with the value surrounded by double quotes, as so:
"[{'SystemID':'ARCS','Timestamp':'2020-01-01 13:01:02.147','CrateNo':'GHK98765','INo':'1212121212'},application/json,FALSE]"
When the value is later evaluated in an Expression Language context and by the JSON functions and operators, the single quote characters are interpreted as legal quote characters.
Here are sample input examples and the resulting string field values and errors:
Input | Result | Error |
---|
test | test | no error |
"test" | test | no error |
'test' | 'test' | no error |
"'test'" | 'test' | no error |
'"test"' | | Warning = Quotation mark in unquoted field |
"\"test\"" | | Warning = Quoted literal not followed by delimiter |
""test"" | | Warning = Quoted literal not followed by delimiter |
"""test""" | """test""" | no error |
this, is a test | | Warning = Incorrect number of fields, got 2, expected 1 |
"this, is a test" | "this, is a test" | no error |
Issue/Introduction
StreamBase Client API syntax supports CSV quote rules for strings.
Feedback
thumb_up
Yes
thumb_down
No