javascript - Create a JSON object dynamically Angular -
i have json object of below format. currently, hard coded. however, dynamically create json.
i have object need loop through , form json object
[ { 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 } ] }]
thanks in advance.
just use native javascript json.parse
var data = [ { 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 } ] }] var json = json.parse(data);
Comments
Post a Comment