scan_jsonescape(3)
β¨ scan_jsonescape(3) β parse JSON escaped string β¨
okay bestie, buckle up π this one lives in the Library Functions Manual, section 3, and it's literally here to un-escape JSON strings for you. no cap.
πΈ NAME πΈ
scan_jsonescape β parse JSON escaped string π¦
π SYNTAX π
#include <libowfat/textcode.h>
size_t scan_jsonescape(const char *src,char *dest,size_t* destlen);
π DESCRIPTION π
so scan_jsonescape reads JSON-escaped text out of src and drops it into dest, leaving you with a whole UTF-8 string in there. it's giving translator energy π.
parsing stops at any of these three things, periodt:
- the
0terminator - invalid input characters
- a double quote that was not escaped
once it's done, it writes the number of bytes sitting in dest into *destlen, and it returns the number of bytes it decoded from src. two numbers, one call, iconic π
the lowkey chaotic part (in a good way):
destcan beNULLπdestlencan beNULLπdestcan besrc(yes, in-place, she contains multitudes)
to make suredestis big enough, you've got two options, bestie: either allocatestrlen(src)+1bytes, or callscan_jsonescapetwice β the first time withdest == NULL, and*destlenwill still be written. that's the trick, iykyk π§
β RETURN VALUE β
scan_jsonescape returns the number of bytes successfully parsed from src. that's it, that's the number π
π EXAMPLES π
scan_jsonescape("test\n\");",buf,&i) -> return 6, i=5, buf="test\n".
look at her go β¨ return 6, i=5, and buf="test\n". ate, no crumbs.
π₯ SEE ALSO π₯
fmt_jsonescape(3)scan_cescape(3)scan_ldapescape(3)
and that's the whole page, bestie π«Ά β scan_jsonescape(3) from the Library Functions Manual, page 3, signed off with love and zero crumbs πβ¨π
π¦ where this page comes from
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms