javascript - How to convert object array into 2d array of parent child hierarchy? -
using declaration multidimensional object (shown below) can make attacksource of label type "inside" contain multiple children e.g "dos","login abuse"
var data = [ { "attacksource": 43, "attacktype": 60, "at":"dos","label": "inisde" }, { "attacksource": 29, "attacktype": 40, "at":"login abuse","label": "outside" } ];
what have tried using js as
var data = [ [{"attacksource": 43,"label":"inside"}], [ {"attacktype": 13,"label":"dos"}, {"attacktype": 13,"label":"virus"} ] ];
is correct assignment task? thanks
what want json. it's not clear whether you're talking transforming existing json or building 1 scratch.
it's hard tell best way represent data without seeing complete picture. if single attack source can have multiple attacks types 1 way represent attack types array.
[ { "attacksource": 43, "label": "inside", "attacktypes": [ {"attacktype": 60, "at":"dos"}, {"attacktype": 18, "at":"virus"} ] } ]
Comments
Post a Comment