Javascript JSON.parse (jsonEmText) works on Linux but not on Windows. How to solve?

1

Hello everyone. I have an HTML page that uses AngularJS to display a JSON that is passed using encodeURI() . On Linux I can pass this JSON with no problems, but when the same page function is done in Windows, it gives format error of JSON .

The code below is JavaScript.

Here I am sending JSON using encodeURI() .

var modalPath = path.join('file://', __dirname, 'paginas/etiqueta/verEtiqueta.html?ETiqueta=' + encodeURI(objProduto)); var win = new BrowserWindow({ width: screen.width, height: screen.height }); win.on('close', function() { win = null }); win.loadURL(modalPath); win.show();

Here I am getting JSON by taking the parameter by the URL and using decodeURIComponent() for it.

var x = location.search.substring(10); var xx = decodeURIComponent(x); var objetoOriginal = JSON.parse(xx);

In linux the variable objetoOriginal receives value of the variable xx and returns a normal object, in Windows the variable objetoOriginal does not receive value and the console returns format error of JSON . In order not to leave the question too long, I leave the "JSON" variable that the xx receives after the decodeURIComponent(x) returns the value, result that the variable xx in that link link

    
asked by anonymous 06.10.2016 / 15:51

1 answer

0

eval

JSON

in the console if we use the command JSON.parse()

// X recebe o JSON da URL cortando fora o inicio que serio o parametro '?Rparametro=' deixando apenas o encodo do JSON returns the type of the variable as an object.

    
06.10.2016 / 16:17