Page 1 of 1

cJSON value string limit?

Posted: Wed May 30, 2018 9:37 am
by Zingemneire
Hi,

It is probably listed somewhere but I can't find it for now: is there a limit on the length of a string you can ask for or provide via the cJSON implementation in ESP-IDF?
I am writing our own parameter storage interface layer which uses NVS to store various parameters in flash and I am wondering if the cJSON implementation can handle the maximum string parameter length of 1984 as defined by the NVS component?

Any help much appreciated.

Re: cJSON value string limit?

Posted: Wed May 30, 2018 1:34 pm
by kolban
In case you don't get an answer here, you might want to search and/or post the question to the cJSON project here:

https://github.com/DaveGamble/cJSON

Re: cJSON value string limit?

Posted: Thu May 31, 2018 3:22 am
by ESP_Angus
Hi Zingemneire,

I'm not a cJSON expert, but I do know that internally a string is stored by cJSON as a "const char *", and that they use standard C functions like strlen() to find the length.

So I would expect that the string length limit is the maximum value of size_t minus 1, ie 2^32 - 2. So several orders of magnitude more than the NVS length limit (or the available addressable memory in an ESP32!)

As I said, there may be some secondary limiting factor I'm not aware of. But I expect not.

Re: cJSON value string limit?

Posted: Thu May 31, 2018 9:51 am
by Zingemneire
Hi Guys,

I got confirmation from GitHub/cJSON. There is no limit except for physical memory limits.