lundi 12 mai 2014

why it is creating array new array while making json object?


Vote count:

0




I am making a json array after watching a json array .I am facing one problem it create array inside the object .but I need to add array inside the parent array I am getting this result



[
{
"a": {
"commandList": [],
"testCaseList": []
},
"testCaseList": []
},
{
"b": {
"commandList": [],
"testCaseList": []
},
"testCaseList": [
{
"b-a-1": {
"commandList": [],
"testCaseList": []
},
"testCaseList": []
},
{
"b-b-2": {
"commandList": [],
"testCaseList": []
},
"testCaseList": []
}
]
},
{
"c-1": {
"commandList": [],
"testCaseList": []
},
"testCaseList": []
}
]


But I need to get this out put



[
{
"a": {
"commandList": [

],
"testCaseList": [

]
},

},
{
"b": {
"commandList": [

],
"testCaseList": [
{
"b-a-1": {
"commandList": [

],
"testCaseList": [

]
},

},
{
"b-b-2": {
"commandList": [

],
"testCaseList": [

]
},

}
]
},

},
{
"c-1": {
"commandList": [

],
"testCaseList": [

]
},

}
]


I try to change this line



item.testCaseList = inputItem.children.map(mapItem);


to change



var obj= JSON.parse(sessionStorage.getItem(inputItem.id)
obj.testCaseList=inputItem.children.map(mapItem)


Then I am getting error


Here is my fiddle http://ift.tt/1onGaMR



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire