Is it possible to send a .json file to the server?

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?

Hi,

Yes, you can access $_POST fields like usual

Maybe

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

In one image the payload and in another the return of setvalue

Just to be clear, you're not sending a JSON file, you're sending a JSON string inside a form field.

So, you'll certainly need to use ParseJSON

Ok, so now the goal should be to troubleshoot why it didn't work. Can you show any error messages and the Set Value?

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.

[
{
"id": 1,
"titulo": "Apenas um texte",
"alt": [
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
}
]
},
{
"id": 2,
"titulo": "Apenas um texte",
"alt": [
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
},
{
"texto": "ABC",
"justificativa": "ABA"
}
]
}
]

Ok, but I need to see your attempt with ParseJSON

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"

Without parseJSON it looks like this

Ok, so now you're certain it's a size problem, maybe Patrick or Teodor can help you

And I can't send the file either. In the payload it is shown as binary. I couldn't get anything from the post. But thanks for the help. Hugs

Hi Ewerton,

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.

1 Like

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...

2 Likes

Thank you for your collaboration.

I did a test by sending it to a webhook and the entire amount really doesn't arrive there.

I'll keep trying to see if it will work with the upload, otherwise I'll have to use an N8N to solve my problem.

Best regards