How to convert uploaded CSV to JSON on the server

Hi
From what I understand of your requirement it seems like you need an asset that can act as a json api. Try the following:

Create a new REST Resource JS asset.

Give the HTTP request a url of:
%globals_get_file^as_asset:asset_url%

In the Javascript processing section the javascript can be the function previous referenced by Douglas:

var data = _REST.response.body;
function csvJSON(csv){

  var lines = csv.split("\n");
  var result = [];
  var headers = lines[0].split(",");

  for(var i = 1; i < lines.length; i++){
	  var obj = {};
	  var currentline = lines[i].split(",");
	  for(var j = 0;j < headers.length; j++){
		  obj[headers[j]] = currentline[j];
	  }
	  result.push(obj);
  }
  return JSON.stringify(result); 
}

var json = csvJSON(data);
print(json);

You can use it by passing a csv file asset id to it in the URL:
http://url-to-restjs-asset/?file=1234

If want want to do stuff on the client side then point the ajax calls to that url to get the JSON version of the data. You’ll need to make sure the REST JS asset doesn’t have any designs/layouts applied that will affect its output.

Thanks
Peter