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 » Mapping a JSON field

Post new topic  Reply to topic
 Mapping a JSON field « View previous topic :: View next topic » 
Author Message
petervh1
PostPosted: Wed Jul 06, 2022 5:38 am    Post subject: Mapping a JSON field Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 132

Hi

I have a basic question. Should be obvious, but I just can't find it.

I'm trying to determine whether a particular field in a JSON input message exists or not. The field is called ObjectID.

The Trace node shows the data as

Code:
(0x01000000:Object):JSON               = ( ['json' : 0x7f66a1af8720]
    (0x01000000:Object):Data = (
      (0x01000000:Object):d = (
        (0x01001000:Array):results = (
          (0x01000000:Object):Item = (
            (0x01000000:Object   ):__metadata = (
              (0x03000000:NameValue):uri  = 'https://xxx('00163E1CA6AA1EE798907658744CED4F')' (CHARACTER)
              (0x03000000:NameValue):type = 'cust.StoreRoot' (CHARACTER)
            )
            (0x03000000:NameValue):ObjectID   = '00163E1CA6AA1EE798907658744CED4F' (CHARACTER)
          )


I even wrote the JSON structure to a queue and viewed it using RFHUTIL:

Code:
d.results.__metadata[1].uri="https:\/\/xxx\/xxx\/xxx\/xxx\/xxx\/xx\/xxx\/xxx('00163E1CA6AA1EE798907658744CED4F')"
d.results.__metadata[1].type="cust.StoreRoot"
d.results.,"ObjectID"[1]="00163E1CA6AA1EE798907658744CED4F"


In my ESQL: I have:


Code:
DECLARE ObjectIDExists BOOLEAN EXISTS(InputRoot.JSON.Data.d.results.",ObjectID".[]);


I've tried numerous combinations but can't seem to match the field.

TIA
Back to top
View user's profile Send private message
abhi_thri
PostPosted: Wed Jul 06, 2022 10:55 pm    Post subject: Reply with quote

Knight

Joined: 17 Jul 2017
Posts: 516
Location: UK

hi...why is ',' appearing before 'ObjectIdD'?...is it part of the field name?

try the below and see...

Code:
IF FIELDNAME(InputRoot.JSON.Data.d.results.ObjectID) IS NOT NULL


or

Code:
IF FIELDNAME(InputRoot.JSON.Data.d.results.",ObjectID") IS NOT NULL
Back to top
View user's profile Send private message
petervh1
PostPosted: Wed Jul 06, 2022 11:06 pm    Post subject: Reply with quote

Centurion

Joined: 19 Apr 2010
Posts: 132

I was also surprised to see the ',' in the RFHUTIL representation. It's definitely there - not a typo on my part.

I ignored that, and coded as per your first suggestion and it worked.

Thanks
Back to top
View user's profile Send private message
timber
PostPosted: Thu Jul 07, 2022 4:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1290

This should also work, and may be a little easier to remember:
Code:

IF EXISTS(InputRoot.JSON.Data.d.results.ObjectID[])
   ...
END IF


Don't forget the [] after the field reference - the EXISTS function only works with arrays.
Back to top
View user's profile Send private message
missing_link
PostPosted: Fri Jul 08, 2022 7:10 am    Post subject: Reply with quote

Acolyte

Joined: 08 Jan 2004
Posts: 60

(Long time since I've been here) - but glad i saw this post earlier...seeing the exact same thing with comma's in the RFHUtil JSON view, which made think wha... for minute. Must just be the way it representing the JSON Output.
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 » Mapping a JSON field
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.