0

Hello all,

I have a function in JS, that I need to translate in Java to be used in my JSP as part of server side script. I need to find out what's the equavalent of JSON.stringify() in Java? This is my current JS function. This functioin takes a CSV file as input, that has tab separated columns, and converts it inot JSON file. But, now the requiremnet is that the CSV files are located on the server, and I can't use JS. I need to use server side scripting to handle this request, either at my JSP level using server side script, or at my servlet level on the server side.

function handleCSV(evt) {
    var file = this.files[0];
    var output = [];
    var reader = new FileReader();
    reader.onload = function(progressEvent){
        var lines = this.result.split('\n');                   
        for(var line = 0; line < lines.length; line++){
            var arrline = lines[line].split('\t');                     
            output[line] = JSON.stringify(arrline);
        }
        document.getElementById("data").innerHTML = JSON.stringify(output);
    };
    reader.readAsText(file);
    btnGenerate.disabled = false;
}
2
Contributors
1
Reply
5
Views
2 Years
Discussion Span
Last Post by peter_budo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.