vardata=[['yourname','myvalue'],['myrname','thivalue']];
functionstring_join(data){
varstr='',arr=[];
for(vari=0;i<data.length;i++){
for(varj=0;j<data[i].length;j++){
data[i][j]=slash(data[i][j]);
}
arr.push(data[i].join('/'));
}
returnarr.join(',');
}
functionslash(string){
returnString(string).replace(/[\\/,]/g,'\\$&');
}
functionstring_split(string){
varc,
cur_str='',
cache=[],
result=[];
for(vari=0;i<string.length;i++){
c=string.charAt(i);
switch(c){
case'\\':
cur_str+=string.charAt(++i);
break;
case'/':
cache.push(cur_str);
cur_str='';
break;
case',':
cache.push(cur_str);
cur_str='';
result.push(cache);
cache=[];
break;
default:
cur_str+=c;
}
}
if(cur_str.length){
cache.push(cur_str);
}
if(cache.length){
result.push(cache);
}
returnresult;
}
varbefore=string_join(data);
console.log(before);
varafter=string_split(before);
console.log(after);