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 Index » WebSphere Message Broker (ACE) Support » ESQL JSON with Array alongside JSON without Array Not workin

Post new topic  Reply to topic
 ESQL JSON with Array alongside JSON without Array Not workin « View previous topic :: View next topic » 
Author Message
EricCox
PostPosted: Wed Apr 26, 2017 10:16 am    Post subject: ESQL JSON with Array alongside JSON without Array Not workin Reply with quote

Master

Joined: 08 Apr 2011
Posts: 292

To all,

Here is my ESQL.

Code:

      SET OutputRoot.JSON.Data TYPE = JSON.Array;
      SET OutputRoot.JSON.Data.customerid = '14895434538383';
      CREATE FIELD OutputRoot.JSON.Data IDENTITY(JSON.Array)Data;      
      SET OutputRoot.JSON.Data.Item[1].accountid = '40001000000001';
      SET OutputRoot.JSON.Data.Item[1].accounttype = 'Checking';
      SET OutputRoot.JSON.Data.Item[1].availablebalance = 14000.00;
      SET OutputRoot.JSON.Data.Item[1].currentbalance = 40000.00;            
      SET OutputRoot.JSON.Data.Item[2].accountid = '40001000000002';
      SET OutputRoot.JSON.Data.Item[2].accounttype = 'Checking';
      SET OutputRoot.JSON.Data.Item[2].availablebalance = 66000.00;
      SET OutputRoot.JSON.Data.Item[2].currentbalance = 66000.00;
      SET OutputRoot.JSON.Data.Item[3].accountid = '60001000000001';
      SET OutputRoot.JSON.Data.Item[3].accounttype = 'Savings';
      SET OutputRoot.JSON.Data.Item[3].availablebalance = 40000.00;
      SET OutputRoot.JSON.Data.Item[3].currentbalance = 40000.00;


When I see the tree I see this. Notice how the customerid is inside the Array. How do I get the customerid to locate outside the array properly?

(0x01000000:Object):JSON = ( ['json' : 0x1f5e6ed0]
(0x01001000:Array):Data = (
(0x03000000:NameValue):customerid = '14895434538383' (CHARACTER)
(0x01000000:Object ):Item = (
(0x03000000:NameValue):accountid = '40001000000001' (CHARACTER)
(0x03000000:NameValue):accounttype = 'Checking' (CHARACTER)
(0x03000000:NameValue):availablebalance = 14000.00 (DECIMAL)
(0x03000000:NameValue):currentbalance = 40000.00 (DECIMAL)
)
(0x01000000:Object ):Item = (
(0x03000000:NameValue):accountid = '40001000000002' (CHARACTER)
(0x03000000:NameValue):accounttype = 'Checking' (CHARACTER)
(0x03000000:NameValue):availablebalance = 66000.00 (DECIMAL)
(0x03000000:NameValue):currentbalance = 66000.00 (DECIMAL)
)
(0x01000000:Object ):Item = (
(0x03000000:NameValue):accountid = '60001000000001' (CHARACTER)
(0x03000000:NameValue):accounttype = 'Savings' (CHARACTER)
(0x03000000:NameValue):availablebalance = 40000.00 (DECIMAL)
(0x03000000:NameValue):currentbalance = 40000.00 (DECIMAL)
)
)

The JSON coming out of the service shows the customerid value but not the name of the tag for some reason.

Here is how it comes to SoapUI with the code shown above.
[
"14895434538383",
{
"accountid": "40001000000001",
"accounttype": "Checking",
"availablebalance": 14000,
"currentbalance": 40000
},
{
"accountid": "40001000000002",
"accounttype": "Checking",
"availablebalance": 66000,
"currentbalance": 66000
},
{
"accountid": "60001000000001",
"accounttype": "Savings",
"availablebalance": 40000,
"currentbalance": 40000
}
]

Here is the JSON which I'm trying to arrive at.
{customerid: "14895434538383"}
[
{
"accountid": "40001000000001",
"accounttype": "Checking",
"availablebalance": 14000,
"currentbalance": 40000
},
{
"accountid": "40001000000002",
"accounttype": "Checking",
"availablebalance": 66000,
"currentbalance": 66000
},
{
"accountid": "60001000000001",
"accounttype": "Savings",
"availablebalance": 40000,
"currentbalance": 40000
}
]
Back to top
View user's profile Send private message
martinb
PostPosted: Wed Apr 26, 2017 1:11 pm    Post subject: Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

Note that the "JSON your are trying to arrive at" is not valid according to http://jsonlint.com/.

As such you cannot build it in the IIB JSON domain.

The top level of the JSON data must be either a JSON Object or a JSON Array.

Are you sure you have the correct format of what you need?
Back to top
View user's profile Send private message
mpong
PostPosted: Wed Apr 26, 2017 7:41 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

what you are trying to achieve is an invalid data. Try something like below.

SET OutputRoot.JSON.Data.customerid='747474747';
CREATE FIELD OutputRoot.JSON.Data.fieldValues IDENTITY(JSON.Array)fieldValues;
SET OutputRoot.JSON.Data.fieldValues.Item[1].type='FieldValue';

Not tested though.
Back to top
View user's profile Send private message
timber
PostPosted: Wed Apr 26, 2017 11:39 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Not sure what this line of ESQL is trying to accomplish...
Code:
CREATE FIELD OutputRoot.JSON.Data IDENTITY(JSON.Array)Data;

Why not just do this, two lines earlier:
Code:
CREATE LASTCHILD OF OutputRoot.JSON IDENTITY(JSON.Array)Data;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL JSON with Array alongside JSON without Array Not workin
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.