I'm trying to use HTML compiler to save and load .json flavored text files. If I use javascript's JSON.stringify and JSON.parse I can encode and decode data fine. However, when I use stringify to get a string and write it to a file, then read it in to a string and use parse, Javascript throws an "unknown character" error.
For what it is worth, I opened the file written by appReadFile and copy and pasted the stringify results into a json validator, and it says the text is valid json.
If I have javascript write out those two strings (the one i write to the file and the one i read from the file, they strings look the same, but javascript says they are not === or ==.
Is it possible that appReadFile is inserting a hidden character somewhere?
Hello Bryce,
Certainly write and read operations don't add nothing to the file to be write or read. Look at the below "index.html" sample, I try it and works as expected after apply the "trim" function, so, probably you need to apply that "trim" function too?
That did it. I'm not sure why JSON.parse can't deal with an extra whitespace character, but it's now working. Thanks!
Hello Bryce,
You're welcome! Certainly, I remember the "space" issue in other environments, languages, etc... I am not completely sure where, but, when you post here the issue, what I first before anything else is to trim the JSON... just because remember that I get the same issue in the past, not related with HTML Compiler!
Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.