10-28-2021 02:33 AM
I have a requirement, where by I need to copy the same data into all the entries in a JSON array. The data I need to copy is
“countryIso” : “GB”
“sessionId” : “ed7e8228-a82b-44e0-adea-caee6c61a987”
I have an typical JSON array structure:
"orderLine": [
{
"orderLineNumber": "000004",
"product": "21909232109737",
"productName": "Avon WT7 Snow (Winter Tyre) 195/65 R15 T (91)",
"quantity": "48",
"unitPrice": "44.34"
},
{
"orderLineNumber": "000013",
"product": "039400014592",
"productName": "Goodyear Eagle F1 Asymmetric 5225/40 R18 Y (92)",
"quantity": "32",
"unitPrice": "38.88"
},
Then I want to copy countryIso and sessionId to each array entry, like this:
"orderLine": [
{
"orderLineNumber": "000004",
"product": "21909232109737",
"productName": "Avon WT7 Snow (Winter Tyre) 195/65 R15 T (91)",
"quantity": "48",
"unitPrice": "44.34",
"countryIso" : "GB",
"orderId" : "ed7e8228-a82b-44e0-adea-caee6c61a987"
},
{
"orderLineNumber": "000013",
"product": "039400014592",
"productName": "Goodyear Eagle F1 Asymmetric 5225/40 R18 Y (92)",
"quantity": "32",
"unitPrice": "11.88"
"countryIso" : "GB",
"orderId" : "ed7e8228-a82b-44e0-adea-caee6c61a987"
},
I have used extend to add the fields, but try as I might I just can’t copy the data to each entry, has anybody done anything similar?
Regards
Jay
11-03-2021 01:04 AM
Thank you for your support and suggestions. I solved this problem, using a stored procedure.