cancel
Showing results for 
Search instead for 
Did you mean: 

can not read JSON content

janaka1984
Star Contributor
Star Contributor
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
2 REPLIES 2

muralidharand
Star Contributor
Star Contributor
Hi,
If you want format the data, you can pass, the json string to your ftl file and your can get the desired output.
If possible, share the output to get helped.

khaledoueslati
Champ in-the-making
Champ in-the-making
hi,
you can use com.google.gson.Gson it parses the JSON XML into object and then u can do what ever you want with it