Introducing the all-new TIBCO Community site!

For current users, please click "Sign In" to reset your password and access the enhanced features. If you're a first-time visitor, we extend a warm welcome—click "Sign Up" to become a part of the TIBCO Community!

If you're seeking alternative community sites, explore ibi, Jaspersoft, and Spotfire.

Jump to content

How to Replace element name with value in JSON


Obdurate -

Recommended Posts

TIBCO BW 5.14 I have below input records:

<Record>

<TESTID>1</TESTID>

<SCHEDULEDAY>2023-08-22</SCHEDULEDAY>

<CUSTID>5</CUSTID>

<MOBILENUMBER>222222222</MOBILENUMBER>

<RADIONUM>12345</RADIONUM>

</Record>

<Record>

<TESTID>2</TESTID>

<SCHEDULEDAY>2023-08-22</SCHEDULEDAY>

<CUSTID>5</CUSTID>

<MOBILENUMBER>222222222</MOBILENUMBER>

<RADIONUM>12345</RADIONUM>

</Record>

<Record>

<TESTID>3</TESTID>

<SCHEDULEDAY>2023-08-26</SCHEDULEDAY>

<CUSTID>6</CUSTID>

<MOBILENUMBER>222222222</MOBILENUMBER>

<RADIONUM>12345</RADIONUM>

</Record>

I want to use SCHEDULEDAY from above request and create JSON like this, where SCHEDULEDAY is used as element tag and both records of same SCHEDULEDAY are combined in jSON output.

Output JSON:

{

"finalData": {

"2023-08-22": [

{

"TESTID": 1,

"CUSTID": 5,

"Mobile": 1232434345,

"radioNum": 11

},

{

"TESTID": 3,

"CUSTID": 5,

"Mobile": 4545454524,

"radioNum": 22

}

],

"2023-08-26": [

{

"TESTID": 5,

"CUSTID": 6,

"Mobile": 4543466759,

"radioNum": 33

}

]

}

}

Link to comment
Share on other sites

  • 2 weeks later...

Hello @Obdurate -​ ,

I believe that natively, the replacement you want to perform is not possible. Complex elements are defined in the XSD schema, which is used to specify the structure of data to be used in your processes. It is not designed to have data elements with dynamic names or that can be substituted with other values at runtime. But, I ask that the experts correct me if I am mistaken.

However, since your message is not so extensive, there's nothing stopping you from building your own logic to meet this need.

Link to comment
Share on other sites

×
×
  • Create New...