I am trying to convert list of string into json object. My string is : personName + rank. This is string is arranged as per the person's rank. PS: the backend code is in solidity My code so far is as follows:
var ranks = new Array(5);
PersonNames = Object.keys(names);
ranks = contractInstance.dashboard.call(PersonNames);// function in solidity
var finalList = [];
for (var j = 0; j < ranks.length; j++){
var winList = web3.toAscii(ranks[j]);
var winCount = contractInstance.RanksFor.call(ranks[j]).toString();
var person = {};
person["name"] = winList[j];
console.log(winList[j]);
person["ranks"] = winCount[j];
finalList.push(person);
}
var myJSON = JSON.stringify(finalList);
Please let me know if I am making use of the correct syntax. I am learning how to implement javascript. Any help would be appreciated. Thank you!!