You are doing double work. Not sure why you would want this rather than to format it as json on the server, and just ajax this to the client formatted as json. But anyway, just to answer your question DEMO:
// your stirng '{1=xxx,2=eee,3=ddd,4=rrr,D=3,R=ttt}';
var MyObjects = [];
//And here is how you use it:
MyObjects = ArrayOfObjects.get('{1=xxx,2=eee,3=ddd,4=rrr,D=3,R=ttt}', 'D=3');
//{"1":"xxx","2":"eee","3":"ddd","4":"rrr"}
console.log(MyObjects[0]);
//Your alerts you needed
console.log(MyObjects[1].D, MyObjects[1].R);
//Function you need
var ArrayOfObjects = (function(){
var splitOn = function(str, char){
var arr = [], pos = str.indexOf(char);
arr.push(str.slice(1, (pos-1)));
arr.push(str.slice(pos, (str.length - 1)));
return arr;
},
getObj = function (str){
var strNew = str.replace(new RegExp('=', 'g'), ':');
var jsonSTR = strNew.replace(/(\w+)|(\d+)/g, '"$1"');
return JSON.parse("{"+jsonSTR+"}");
};
return {
get: function(string, spl){
var strings=splitOn(string, spl), retArr = [];
strings.forEach(function(str){
retArr.push(getObj(str));
});
return( retArr );
}
};
})();
Again This is just an answer to your question, not the solution. The solution would be to form a correct JSON on server side.