AnsweredAssumed Answered

can not read JSON content

Question asked by janaka1984 on Jun 13, 2014
Latest reply on Jul 26, 2014 by khaledoueslati
hi expert,

i used json file like below

hello.json

{"xx":[{

"World":[{

"country":[{
"name":"America",
"Area": [
{
"areaname":"wosington",
"target":{}
},
{
"areaname":"florida",
"target":{}
}
]
}]

}]
}]

}

——————————————————————————-

To read above json content , i use server side js file. (hello.get.js)

function main() {
var data = get_config();

var x = [];

for(var i = 0; i< data.xx.length; i++){ //loop to get outer
for(var j = 0; j< data.xx.world.length; j++){ //loop to get advance search
for(var k = 0; k< data.xx.world[j].country.length; k++){ //loop to get study DB
for(var t = 0; t< data.xx.world[j].country[j].area[k].areaname.length; t++){//loop to get option
template_details[t] = data.xx.world[j].country[j].area[k].areaname[t].areaname;
}
}
}
}

model.responses = x;

}

function get_config() {

var configfile = companyhome.childByNamePath("/country/hello.json");
var serverCfg = configfile.content;

return jsonUtils.toString (eval('(' + serverCfg + ')'));


}

main();

——————————————————————————-

pls correct me or give solution to solve this problem.

hints: var data = get_config(); (need to check whether it can assign )

Thanks

hewa

Outcomes