I currently have a JSON object structured in the following format. Although it's hardcoded at the moment, I'm looking to dynamically generate this JSON by looping through another object.
The second object should be iterated over in order to construct the JSON object with the given structure.
[
{
name: "test1",
enable: true,
unit: 24350,
unit_price: 1.0368,
composition: [
{
asset: "asset1",
percentage: 15
},
{
asset: "asset2",
percentage: 10
},
{
asset: "asset3",
percentage: 5
},
{
asset: "asset4",
percentage: 35
},
{
asset: "asset5",
percentage: 20
},
{
asset: "asset6",
percentage: 15
}
]
},
{
name: "test2",
enable: true,
unit: 24350,
unit_price: 1.0368,
composition: [
{
asset: "asset1",
percentage: 15
},
{
asset: "asset2",
percentage: 10
},
{
asset: "asset3",
percentage: 5
},
{
asset: "asset4",
percentage: 35
},
{
asset: "asset5",
percentage: 20
},
{
asset: "asset6",
percentage: 15
}
]
}
]
Thank you in advance for your assistance.