Is it possible to send a .json file to the server?
I have a json file with thousands of lines and I would like to send it to the server where I will get the data and use it in a repeat to save it in the database.
I tried to send the data directly, but I think it's not working because of the size.
In Paylod the array appears formatted correctly, but on the server it arrives very out of order, like [\r\n {\r\n "disciplina_id": 1,\r\n or like this ["","{ "disciplina_id": 2,
I've tried parseJSON() and it didn't work
Is it possible to send the file and get the data there: like we do with CSV?
Please show all evidence that led you to this conclusion. This statement is not compatible with your theory about the JSON size, it's probably a different issue
I'm showing the reason I want to send the file, since the string didn't work. See in this image that I reduced its size just for testing and pasted it directly into the setvalue. It worked. The same content when it leaves the frontend and goes to the server doesn't look like this.
It worked with this shortened version. But not with the entire file. I tested the file on https://jsonformatter.org/ and it is ok. It has 5007 lines.
However, when I send it, I get this error. Sometimes another error appears
{status: "500", message: "Unterminated string in JSON at position 1015804 (line 4313 column 390)",…}
message
:
"Unterminated string in JSON at position 1015804 (line 4313 column 390)"
stack
:
"SyntaxError: Unterminated string in JSON at position 1015804 (line 4313 column 390)\n at JSON.parse ()\n at parseJSON (/opt/node_app/lib/formatters/core.js:24:21)\n at /opt/node_app/lib/core/parser.js:670:26\n at parser (/opt/node_app/lib/core/parser.js:359:19)\n at Object.parseValue (/opt/node_app/lib/core/parser.js:732:24)\n at App.parse (/opt/node_app/lib/core/app.js:747:19)\n at App.setvalue (/opt/node_app/lib/modules/core.js:170:26)\n at App._exec (/opt/node_app/lib/core/app.js:722:49)\n at App._exec (/opt/node_app/lib/core/app.js:689:20)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)"
status
:
"500"
I recently came across a similar issue with size of the JSON payload. In my case, the app is ingesting JSON payload from an external source, which is much larger in size than the standard limit in the wappler setup.
You can increase the payload size limit in server.js file. However, it will require a regular maintenance as this file gets overwritten during each wappler update. Note: modifications in index.js are specific to my project.
The problem with guptast's solution is that it doesn't apply to you, because you're sending JSON in a form field, so you'd need to increase the allowed input form field size or something...