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