Hacker News new | ask | show | jobs
Show HN: 106-byte JSON field extractor for embedded (8× smaller than JSMN) (github.com)
3 points by CoreLathe 244 days ago
Single-header JSON field extractor for when you control both message format and receiver. 106 bytes on ARM Cortex-M4, no malloc, MIT licensed.

    #include "packet_atoms.h"
    char temp[16];
    jet("{\"temp\":22.5,\"hum\":65}", "temp", temp, sizeof(temp));
    // temp now holds "22.5"
Deliberate limitations: - Fixed field order (uses strstr) - No nested objects/arrays - Strings include quotes - You design the protocol

Size comparison (ARM ‑Os): - cJSON: 3.2 kB + malloc - JSMN: 800 B + token iteration - This: 106 B

Tested on Cortex-M4 and x86-64. Header-only, copy-paste ready.