I have a returned object list: data.d[15]
and one sample of it:
data.d[3] = {
CityId: 2,
CityName: "Ankara"}
I want to convert it to one object as
cities{
1: "Istanbul",
2: "Ankara",
3: "New York"
}
And it should be generic, so I dont know the "CityId" and "CityName" field names. what is the best method for it?
thank you all... i have send fieldnames by field object -no dependencies important for this code-, it has been resolved.
var url = this.options.url + "/" + field.values,
id = field.fieldId,
title = field.fieldTitle;
this.getJSON(url, {}, function (rData) {
var obj = {};
for (i = 0; i < rData.d.length; i++)
obj[rData.d[i][id]] = rData.d[i][title];
$("#" + parentId).html(self.getHtmlOfFormData(type, obj));
});
CityName, then how are we supposed to know what to project?