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 » parsed blob data needs to be assesed if its JSON or XML

Post new topic  Reply to topic
 parsed blob data needs to be assesed if its JSON or XML « View previous topic :: View next topic » 
Author Message
gakd1987
PostPosted: Tue Nov 17, 2015 9:59 am    Post subject: parsed blob data needs to be assesed if its JSON or XML Reply with quote

Apprentice

Joined: 20 Aug 2013
Posts: 26

I have a flow in which we are invoking a restful service using HTTPRequest node and that request hits the datapower and gives back the response and the response from datapower is expected to be JSON. We are getting back JSON response in most of ideal cases except 1 scenario i.e. when the datapower timesout while processing the request and returns back XML as response and it fails in the HTTPRequest node. Ideally the datapower has to return JSON but due to some constraint the changes in DP is in prgress but mean while we are thinking to change the PARSER in the httprequest node to BLOB and then we would write a function to check if the BLOB is really a XML or JSON and reparse it accordingly. Is there a way to check if the BLOB is XML or JSON before its parsed by RCD node?
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Nov 17, 2015 11:02 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Look at the first character and see if is a <
You can cast the < as a blob and then extract the same length from the input BLOB.
IF they match then you have XML otherwise assume it is JSON.

There are probably other ways.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Nov 17, 2015 11:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

use create lastchild domain.

catch exceptions.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
timber
PostPosted: Tue Nov 17, 2015 11:42 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
Look at the first character and see if is a <
If it works once then it will probably work every time. But it only works when the document does not start with a Byte Order Mark.
mqjeff's suggestion will always work.
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 » parsed blob data needs to be assesed if its JSON or XML
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.