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 » Casting BLOB to JSON

Post new topic  Reply to topic
 Casting BLOB to JSON « View previous topic :: View next topic » 
Author Message
Lone_Wanderer
PostPosted: Tue Jan 17, 2017 4:36 am    Post subject: Casting BLOB to JSON Reply with quote

Newbie

Joined: 16 Jan 2017
Posts: 8

A have a stiation where I'm parsing BASE64 encoded file. To decode the file, I use following code:
Code:

                DECLARE EncTokenHead CHAR InputLocalEnvironment.REST.Input.Parameters.head1;
      DECLARE EncTokenBody CHAR InputLocalEnvironment.REST.Input.Parameters.body1;
      DECLARE EncTokenSign CHAR InputLocalEnvironment.REST.Input.Parameters.sign1;

      DECLARE DecTokenHead BLOB BASE64DECODE(EncTokenHead);
      DECLARE DecTokenBody BLOB BASE64DECODE(EncTokenBody);
      DECLARE DecTokenSign BLOB BASE64DECODE(EncTokenSign);

      DECLARE CasTokenHead CHAR CAST(DecTokenHead AS CHARACTER CCSID 1208);
      DECLARE CasTokenBody CHAR CAST(DecTokenBody AS CHARACTER CCSID 1208);
      DECLARE Affinity CHAR ;


Now last 3 lines are responsible for casting the resulting blob into something more readable. The problem is, that the result is character and therefore is not handled as JSON. Now I need to access some values inside that JSON and that cannot be really easilly done with one long string I'm stuck here with. Is there a way to cast those CHARs into JSON directly usinq ESQL?
Thanks for any advices
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jan 17, 2017 5:30 am    Post subject: Re: Casting BLOB to JSON Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Lone_Wanderer wrote:
Is there a way to cast those CHARs into JSON directly usinq ESQL?


You can't cast any of the variable types into any of the message domains (JSON, XCLNSC, etc) and vice versa.

Use CREATE with the PARSE option to parse (unsurprisingly) the data and create the message tree. Use ASBITSTREAM to perform the reverse, i.e. flatten a message tree into a simple variable type.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » Casting BLOB to JSON
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.