akheron / jansson

C library for encoding, decoding and manipulating JSON data
http://www.digip.org/jansson/
Other
3.05k stars 809 forks source link

find the json_t object size in bytes #549

Closed zuoshuluHTC closed 3 years ago

zuoshuluHTC commented 4 years ago

I am working on a program that runs on a hardware with a very small size RAM, it seemed like I ran out of memory. Is there a way to find out how big is a json_t object, my object includes some directories of different values like integer, string, and boolean. I tried the sizeof function, but it always return 4.

akheron commented 3 years ago

I'm afraid there's no such function. A json_t is a complex value, and its size may differ greatly if the value is e.g. an object.