ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportSubstring before newline

Post new topicReply to topic
Substring before newline View previous topic :: View next topic
Author Message
wmqstankela
PostPosted: Wed Apr 24, 2019 2:22 am Post subject: Substring before newline Reply with quote

Voyager

Joined: 29 Feb 2016
Posts: 94

Hi all,

I'm using iib V10 and I exposed some REST service on it. I have input parameter which is char and sometimes clients send me string with newline in it. i want to substring everything before newline.

I've tried this, but it doesn't work
Code:

DECLARE CR CHAR CAST(CAST('X''0A''' AS BLOB) AS CHAR CCSID InputRoot.Properties.CodedCharSetId);
DECLARE temp CHAR;
SET temp = SUBSTRING(InputRoot.JSON.Data.beneCustName BEFORE CR);

or
Code:

SET temp = SUBSTRING(InputRoot.JSON.Data.beneCustName BEFORE '
');


Can someone help with this?
Back to top
View user's profile Send private message
timber
PostPosted: Wed Apr 24, 2019 3:27 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1003

The string in the message tree is in UTF-16, not InputRoot.Properties.CodedCharSetId.

Also, you don't need to CAST X'0A' as BLOB. It's already a BLOB. You should get into the habit of reading the language reference: https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ak17840_.htm
Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Apr 24, 2019 5:33 pm Post subject: Re: Substring before newline Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1365

wmqstankela wrote:
I have input parameter which is char and sometimes clients send me string with newline in it.

Unparsed JSON strings should not have literal control characters, including any end-of-line characters. Instead they should have escape sequences, like "\n" for line feed (LF), and "\r" for carriage return (CR). What does the unparsed JSON look like?

wmqstankela wrote:
I've tried this, but it doesn't work

"doesn't work" is a bit vague. A usertrace might describe more completely what it does do.

wmqstankela wrote:
Code:
DECLARE CR CHAR CAST(CAST('X''0A''' AS BLOB) AS CHAR CCSID InputRoot.Properties.CodedCharSetId);

The variable name for the converted BLOB literal (X'0A') would usually be "LF", not "CR". Regardless, the BLOB does not come from the input message, so it should not depend on the input ccsid. Since it is hard-coded, the ccsid can be, too; any ASCII-based ccsid will do, such as 367 (US-ASCII), 819 (ISO-8859-1), or 1208 (UTF-8):

Code:
DECLARE LF CHAR CAST(X'0A' AS CHAR CCSID 819);

Of course, it would still help to know what end-of-line character sequence to expect in the input. Is it just an LF, or could it be CR+LF, or maybe something else?

wmqstankela wrote:
Code:
SET temp = SUBSTRING(InputRoot.JSON.Data.beneCustName BEFORE '
');

Embedding a literal end-of-line sequence in a CHAR string is unreliable. That is why developers make the extra effort to CAST BLOB literals to CHAR in the first place.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportSubstring before newline
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.