1
Hello, everyone. I have an HTML page that uses Angularjs to display a JSON
that is passed by using the encodeURI()
. On Linux I can pass this JSON
without problems, but when the same page function is done on Windows, it gives formatting error JSON
.
The code below is Javascript.
Here I am sending the JSON using the 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 the JSON by taking the parameter by URL and using decodeURIComponent()
for that reason.
var x = location.search.substring(10);
var xx = decodeURIComponent(x);
var objetoOriginal = JSON.parse(xx);
In linux the variable objetoOriginal
receives variable value xx
and returns a normal object, whereas in Windows the variable objetoOriginal
does not receive value and the console returns format error from JSON
.
To not leave the question too extensive, I leave the "JSON" that variable xx
receives after the decodeURIComponent(x)
return the value, result that the variable xx
at that link http://pastebin.com/JwnAEqC5