zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.72k stars 783 forks source link

jsmntok_t with smaller size type #239

Open jcecconi opened 3 months ago

jcecconi commented 3 months ago

Sometimes, in embedded devices like the ESP32, using the 'int' type implies using 32 bits, which is often unnecessary. If you then need to use an array of this struct, it could consume a lot of stack memory. This is why I propose using uint16_t in the following way:

Iifdef USE_JSMNTYPE_UINT16

typedef struct jsmntok { jsmntype_t type; uint16_t start; uint16_t end; uint16_t size;

ifdef JSMN_PARENT_LINKS

uint16_t parent;

endif

} jsmntok_t;

endif