I am new in javascript and angular. Suppose I have an JSON object with {"xyz":{Key:info}}
. I want to add {Key:info}
in to an array .
I want to make "xyz" an array. Eg: {"xyz":[{Key:info}]}
So that I can push more of {Key:info}
into that array- {"xyz":[{Key:info},{Key:info},{Key:info}]}
.
Also I need to check every time if xyz is object then make it array and push only once.
I am not getting how can I do this with angular javascript.
EDIT :-Added orig JSON
$scope.ContentObj= { "attribute-set": [ { "attribute": [ { "_name": "text-align", "__prefix": "xsl", "__text": "end" }, { "_name": "end-indent", "__prefix": "xsl", "__text": "10pt" } ], "_name": "odd__header", "__prefix": "xsl" }, { "attribute": { "_name": "font-weight", "__prefix": "xsl", "__text": "bold" }, "_name": "pagenum", "__prefix": "xsl" } ], "_version": "2.0", "__prefix": "xsl" }