I need to use cJSON to parse the uart data. I found the file in SDK15.3 but how can I use the related function?
I need to use cJSON to parse the uart data. I found the file in SDK15.3 but how can I use the related function?
Hi,
just add sources and headers to your project and call functions as usual... you also need to add mem_manager library from SDK. cJSON has a good README with detailed instructions how to use this library.
Hi,
just add sources and headers to your project and call functions as usual... you also need to add mem_manager library from SDK. cJSON has a good README with detailed instructions how to use this library.
Hi,
I have already used the cJSON library, but now there is a problem. When the data length is too long, the parsing fails. (The data format is normal.) I suspect that the heap size is not enough. Can you tell me how to use the mem_manager library to manage the space size, and Meaning of the parameter?
Now, I am using cJSON_malloc, cJSON_free (equivalent to the C standard function malloc, free) to manage the space size.
Hi,
Now I can successfully parse the json data and successfully create the json data. But as long as the data is too long, it will fail to build or parse. I suspect that using the standard library malloc will cause a memory leak. Is my suspicion correct? How to use the memory management library? And What should I do next?
June6
Is there a routine example of how to use the memory management library?
Hi,
the only thing you need is to define some number of memory blocks in sdk_config.h, there are several sizes of memory blocks. Since I don't know neither the length and count of your json strings, nor the logic of your program, I cannot suggest you an optimal configuration. You can enable logging of memory manager in sdk_config and see how much memory is requested. Try to configure as much memory as possible, then run your build/parse tasks and call nrf_mem_diagnose(), it will show some memory usage statistics.
cJSON with memory manager is used by background_dfu example in SDK, you can look at its config.