Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Trying to bulid a JSON object using QM data collections tools

98 views
Skip to first unread message

jaya...@gmail.com

unread,
Jun 6, 2022, 9:23:17 AM6/6/22
to OpenQM
Hello:

OpenQM properly JPARSEs the object listed below, but I am pulling my hair our trying to create an object like this from scratch. I've tried various combinations of inserting MATs, etc but I can't seem to get the "id" and "fields"properties to co-exist happily as their own "sub-objects" or "sub arrays". Any help would be so much appreciated.

Thanks!

Jay Alosa

{
   "records":[
      {
         "id":"recvJxU4tRJtIXdyb",
         "fields":{
            "Stock":"001578",
            "Year":"2018",
            "Make":"CHEVROLET",
            "Model":"BBSCHOOLBUS",
            "FullVIN":"1xxxxx001578",
            "Status":"A",
            "NorU":"N",
            "Mileage":"31746",
         }
      },
      {
         "id":"recZGruOONyx4CuxQ",
         "fields":{
            "Stock":"132759",
            "Year":"2005",
            "Make":"BLUEBIRD",
            "FullVIN":"2XKBBSDFFF32759",
            "Status":"A",
         }
      },
      {
         "id":"recEI7xMqzEToatLQ",
         "fields":{
            "Stock":"215389",
            "Year":"2022",
            "Make":"HINO",
            "FullVIN":"215389",
            "Location":"KBUR",
            "OwnedBy":"KBUR",
            "Status":"A",
            "NorU":"N",
         }
      }
   ]
}

Martin Phillips

unread,
Jun 6, 2022, 10:06:17 AM6/6/22
to ope...@googlegroups.com

Jay,

 

You could build the whole thing element by element from the top down or you could build the fields element as a separate collection and then add pairs of ids and fields as needed. I prefer the second method but it should not make a huge difference.

 

Here is my code to assemble your sample result. The real program would clearly need a loop to process each record in turn.

 

* Create collection to hold final result

result = collection()

result{“records”} = mat()

 

* Build detail for this vehicle

detail = collection()

detail{“Stock”} = “001578”

detail{“Year”} = “2018”

…etc…

 

* Build record for this vehicle

record = collection()

record{“id”} = “recvJxU4tRJtIXdyb”

record{“fields”} = detail

 

* Store record in result

result{“records”, -1} = record

 

Please let me know if this helps.

 

 

Martin

 

 

 

From: ope...@googlegroups.com <ope...@googlegroups.com> On Behalf Of jaya...@gmail.com
Sent: 06 June 2022 14:23
To: OpenQM <ope...@googlegroups.com>
Subject: Trying to bulid a JSON object using QM data collections tools

 

EXTERNAL EMAIL

================================
Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy
================================

This communication and any attachments may contain confidential information of Rocket Software, Inc. All unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please notify Rocket Software immediately and destroy all copies of this communication. Thank you.

jaya...@gmail.com

unread,
Jun 6, 2022, 2:01:37 PM6/6/22
to OpenQM
Thank you Martin!

I was struggling with the "result" data collection being the one (and only one) needing to be MATed. This worked perfectly :-)
Reply all
Reply to author
Forward
0 new messages