I need to create a json object from scratch where each key has several values / values example:
'{"name":["daniel","dias"],"morada":["joao","allen"]}'
For this I am executing this code several times, but the result is presented with numeric generated keys:
facetaPush - key name
response - array with desired values
valuesFacts - save json final object
var json_string = "";
json_string +='{\"'+facetaPush+'\":[' ;
for (var i = 0; i < response.length-1; i++) {
json_string +='\"'+response[i]+'\",';
}
json_string +='\"'+response[response.length-1]+'\"]}';
var json_obj = JSON.parse( json_string );
valuesFacetas[facetaPush].push(json_obj);
alert("valores facetas: "+valuesFacetas[facetaPush][facetaPush]);