lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Best way to return JSON data for AJAX


From: Trampas Stern
Subject: Re: [lwip-users] Best way to return JSON data for AJAX
Date: Mon, 20 Apr 2020 16:59:39 -0400

What I did was use the fs.c example, and when user requests a file like '/json' I create a string on micro with the json and send back using the fs.c api.   The restriction here is that I send a JSON no bigger than my string size, which is statically allocated. 

To send json to the micro I have used http POST messages and when I get the application/json content tag I then store the JSON file on SD card (as they can be 100k or more) and then once the post is done I parse the JSON on the micro.  To parse the large json file I wrote a custom parser which limits the memory usage during parsing. 

I also found that my uploading files was really slow, due to number of buffers, so I had to increase buffers.  However the maximum bit rate I am getting is around 1mbps, which is not great, but good enough for what I need. 

Trampas



On Mon, Apr 20, 2020 at 2:59 PM Dave Nadler <address@hidden> wrote:
Thanks Marco and Adam for the suggestions.
This works great:
- create a fixed local JSON file with SSI-include syntax for the values to substitute (lwIP's included httpd processes JSON type for SSIs).
- #define LWIP_HTTPD_SSI 1
- #define LWIP_HTTPD_SSI_MULTIPART 1
- #define LWIP_HTTPD_SSI_INCLUDE_TAG 0 // Otherwise, SSI substitution leaves original tag in JSON/HTML as a comment

I did not address trying to create a much larger file dynamically, though a short JSON could be expanded arbitrarily if set up as above.
Also I didn't address context-identification which may be required for multiple connections and multi-part responses;
this part isn't obvious...

Thanks again for the help,
Best Regards, Dave

On 4/15/2020 12:17 PM, Dave Nadler wrote:

Hi All - I'm looking for guidance on good ways to return JSON data for use in a web page via AJAX.
I found a couple of threads discussing using SSI for this but I'm unclear the overall approach.
For this application I don't need to worry about session IDs - just need to return some JSON
data, in multiple chunks to avoid chewing up enormous memory in prep.
Thanks in advance for any guidance (or even better an example!),
Best Regards, Dave

References:
https://lists.gnu.org/archive/html/lwip-users/2017-11/msg00137.html
http://lwip.100.n7.nabble.com/LWIP-HTTPD-SSI-MULTIPART-and-concurrent-HTTP-requests-td31266.html


-- 
Dave Nadler, USA East Coast voice (978) 263-0097, address@hidden, Skype 
 Dave.Nadler1
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

[Prev in Thread] Current Thread [Next in Thread]