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 (ACE) SupportCollection+JSON PUT WebService

Post new topicReply to topic
Collection+JSON PUT WebService View previous topic :: View next topic
Author Message
ChecoTirado
PostPosted: Mon Feb 01, 2016 1:38 pm Post subject: Collection+JSON PUT WebService Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

hi Everyone, I need your help.

I'm building a REST Webservice with the PUT tag but I don't know how to read the next structure as INPUT:

{ "template" : {
"data" : [
{"name" : “periodo”, "value" : “201313”},
{"name" : “folio”, "value" : “5”},
{"name" : “cumple”, "value" : “SS”},
{"name" : “usuario”, "value" : “WS”}
]
}
}

I'm trying with InputRoot object, but I don't know how.
SET cTemp = InputRoot.JSON.Data.template.data.item[1].name.value;

Please advise.

Checo.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Feb 01, 2016 1:43 pm Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Once a message has been parsed by IIB, then you do not care whether it's REST or JSON or XMLNSC or DFDL or etc. etc. etc.

You treat it as a logical message tree.

Any of the samples that come with the product will show you how to navigate the logical message tree.

This is basic IIB programming. You should read the docs, study the samples, and try them.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
ChecoTirado
PostPosted: Mon Feb 01, 2016 1:52 pm Post subject: Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

I tryed with the examples but I didn't found with this type of structure. Would you like to guide me how to read these kind of structure?

Please
Back to top
View user's profile Send private message
ChecoTirado
PostPosted: Mon Feb 01, 2016 2:13 pm Post subject: Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

I got these error

"code": 5701,
"message": "5701: A JSON parsing error has occurred whilst parsing the JSON document \"[\", \"{\", \"value\""
Back to top
View user's profile Send private message
sumit
PostPosted: Mon Feb 01, 2016 2:57 pm Post subject: Reply with quote

Partisan

Joined: 19 Jan 2006
Posts: 398

ChecoTirado wrote:

{ "template" : {
"data" : [
{"name" : “periodo”, "value" : “201313”},
{"name" : “folio”, "value" : “5”},
{"name" : “cumple”, "value" : “SS”},
{"name" : “usuario”, "value" : “WS”}
]
}
}
.....

I got these error

"code": 5701,
"message": "5701: A JSON parsing error has occurred whilst parsing the JSON document \"[\", \"{\", \"value\""

Any JSON message that you want IIB to parse should be a valid JSON message.
Please refer this link to understand how to work with a JSON message in IIB.

https://www-01.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/bc28410_.htm?lang=en
_________________
Regards
Sumit
Back to top
View user's profile Send private message Yahoo Messenger
sumit
PostPosted: Mon Feb 01, 2016 3:02 pm Post subject: Reply with quote

Partisan

Joined: 19 Jan 2006
Posts: 398

hint: there are few invalid JSON characters in your sample JSON message. Rectify and validate it first.
_________________
Regards
Sumit
Back to top
View user's profile Send private message Yahoo Messenger
ChecoTirado
PostPosted: Mon Feb 01, 2016 3:13 pm Post subject: Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

I read the example you sent, but I dont understand is how to use the InputRoot object to parse this specific structure.

This structure is Collection+JSON. http://amundsen.com/media-types/collection/

Ive been able to use the OutputRoot object to return this structure but I dont know how to receive it as input.

I checked the JSON

{ "template" : {
"data" : [
{"name" : "periodo", "value" : "201313"},
{"name" : "folio", "value" : "5"},
{"name" : "cumple", "value" : "SS"},
{"name" : "usuario”, "value" : "WS"}
]
}
}

I'm using this line: SET cTemp = InputRoot.JSON.Data.template.data.item[1].data.item[1].name;
to get "periodo" into the cTemp variable.

Whats wrong?

Please advise
Back to top
View user's profile Send private message
Simbu
PostPosted: Mon Feb 01, 2016 9:50 pm Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Hi, use http://jsonlint.com/ copy & paste your json message, validate it and fix the error with the json. Next, Please test and check the logical tree structure of your json message in the debug to ensure that your json is parsed successfully.
Back to top
View user's profile Send private message
stoney
PostPosted: Mon Feb 01, 2016 9:58 pm Post subject: Reply with quote

Centurion

Joined: 03 Apr 2013
Posts: 140

Quote:
{ "template" : {
"data" : [
{"name" : "periodo", "value" : "201313"},
{"name" : "folio", "value" : "5"},
{"name" : "cumple", "value" : "SS"},
{"name" : "usuario”, "value" : "WS"}
]
}
}

I'm using this line: SET cTemp = InputRoot.JSON.Data.template.data.item[1].data.item[1].name;


You have too many arrays in the ESQL; there's only one in the JSON you've posted. You've also got a lowercase 'i' in your Item. Should be:

SET cName = InputRoot.JSON.Data.template.data.Item[1].name

Quote:

SET cTemp = InputRoot.JSON.Data.template.data.item[1].name.value;


You need to read name and value as two separate elements:

SET cName = InputRoot.JSON.Data.template.data.Item[1].name;
SET cValue = InputRoot.JSON.Data.template.data.Item[1].value;
Back to top
View user's profile Send private message
ChecoTirado
PostPosted: Mon Feb 01, 2016 9:59 pm Post subject: Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

Done, this site says the JSON is valid.
Back to top
View user's profile Send private message
ChecoTirado
PostPosted: Mon Feb 01, 2016 10:15 pm Post subject: Reply with quote

Newbie

Joined: 01 Feb 2016
Posts: 6

stoney wrote:
Quote:
{ "template" : {
"data" : [
{"name" : "periodo", "value" : "201313"},
{"name" : "folio", "value" : "5"},
{"name" : "cumple", "value" : "SS"},
{"name" : "usuario”, "value" : "WS"}
]
}
}

I'm using this line: SET cTemp = InputRoot.JSON.Data.template.data.item[1].data.item[1].name;


You have too many arrays in the ESQL; there's only one in the JSON you've posted. You've also got a lowercase 'i' in your Item. Should be:

SET cName = InputRoot.JSON.Data.template.data.Item[1].name

Quote:

SET cTemp = InputRoot.JSON.Data.template.data.item[1].name.value;


You need to read name and value as two separate elements:

SET cName = InputRoot.JSON.Data.template.data.Item[1].name;
SET cValue = InputRoot.JSON.Data.template.data.Item[1].value;


Thank Stoney, This works perfectly.
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 (ACE) SupportCollection+JSON PUT WebService
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.