|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Double quotes separated with Commas for a string |
« View previous topic :: View next topic » |
Author |
Message
|
nick405 |
Posted: Tue Jun 22, 2021 3:28 pm Post subject: Double quotes separated with Commas for a string |
|
|
Newbie
Joined: 19 May 2014 Posts: 4
|
I am building a JSON request to call an internal REST webservice. The Request was built perfectly but missing closed double quote for every number before the comma seperated.
For example -- I am able to send to REST service as
"accountNumbers":["57575757,11005647"]
But the required Out put is
"accountNumbers":["57575757","11005647"]
Logic Used -- SET OutputRoot.JSON.Data.(JSON.Array)accountRestrictionTransactions.Item[1].(JSON.Array)accountNumbers.Item[1] = Environment.Variables.acctNumbersList ;
This particular Environment.Variables.acctNumbersList will have the below
acctNumbersList:CHARACTER:57575757,11005647
Can you help with this double quote per number in this string as I tried || and other options to break it down which did not work |
|
Back to top |
|
 |
timber |
Posted: Tue Jun 29, 2021 11:34 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Your ESQL is creating a JSON array with one value : "57575757,11005647"
You need to create a JSON array with two values, like this (not tested):
Code: |
CREATE refArray REFERENCE TO OutputRoot.JSON.Data.(JSON.Array)accountRestrictionTransactions;
CREATE LASTCHILD OF refArray TYPE NameValue Name 'Item' Value '57575757';
CREATE LASTCHILD OF refArray TYPE NameValue Name 'Item' Value '11005647'; |
You could do the same thing with Item[1], Item[2] but the CREATE LASTCHILD technique is easier to extend - especially if you use a FOR loop.
But hopefully, Environment.Variables.acctNumbersList is an array and not a CHARACTER variable containing commas. So it would be easier to do this
Code: |
SET OutputRoot.JSON.Data.(JSON.Array)accountRestrictionTransactions.Item[] =
SELECT
accNum AS Item
FROM
Environment.Variables.acctNumbersList AS accNum;
|
Again, this is not tested code and probably does not work as-is. But hopefully it's enough to put you on the right track. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|