Question

How to parse array or array of JSON objects

  • 20 December 2021
  • 2 replies
  • 375 views

Hello

How to parse a JSON structure like below and store in database/tables

 

{
"_id": "12345",
"machineId": "1001001366",
"activation": [{
"activationId": 15589783,
"activationActionCode": "ACTIVATE",
"activationDetail": [{
"activationDetailId": 1001001665,
"productInfo": {
"activationProductId": "138591",
"skurr": "109-000-034"
},
"licMovCountLimit": "5",
"entitlementInfo": {
"dlfEntitlementId": "DLF000028770",
"lac": "CW943GTXK37QSQ29355M",
"siteInfo": {
"siteNumber": 673333,
"companyDuns": "G005358932"
}
},
"companyInfo": {
"companyName": "abc CORPORATION",
"regUser": [{
"userId": "10536",
"email": "10533@gggggg.com"
}]
},
"isOriginal": "-1"
}],
"activationKey": [{
"activationKeyId": 1001001398,
"type": "licr455"
}]
}],
"status": "ACTIV"
}

 

Does it need custom coding or off the shelf components can do it

 


2 replies

Userlevel 5
Badge

@dima @palak 

Userlevel 3
Badge

Hi @rajneesh75 

I would try to pivot the input JSON and then flatten it so that these records then can be stored in DB (in a relational DB) where you want to store every KEY under a COLUMN.

 

Use of field pivot on LIST type columns will ensure that we generate multiple records from a single JSON.

You may have a look at the attached one.

Reply