cJSON value string limit?

Zingemneire
Posts: 68
Joined: Tue Apr 17, 2018 7:35 am

cJSON value string limit?

Postby Zingemneire » Wed May 30, 2018 9:37 am

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.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: cJSON value string limit?

Postby kolban » Wed May 30, 2018 1:34 pm

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
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: cJSON value string limit?

Postby ESP_Angus » Thu May 31, 2018 3:22 am

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.

Zingemneire
Posts: 68
Joined: Tue Apr 17, 2018 7:35 am

Re: cJSON value string limit?

Postby Zingemneire » Thu May 31, 2018 9:51 am

Hi Guys,

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

Who is online

Users browsing this forum: Majestic-12 [Bot] and 84 guests