ASON_READ(3)
π ASON_READ π
okay bestie, pull up a chair, we're talking about ASON_READ(3) from the User Manuals section β yes it's a real manpage and yes it's about parsing β¨
πΈ NAME πΈ
ason_read, ason_readn β parse ASON values into ason_t objects. that's it, that's the whole job, and they ate π
β¨ SYNOPSIS β¨
#include <ason/ason.h>
#include <ason/read.h>
ason_t *ason_read(const char *text, ...);
ason_t *ason_readn(const char *text, size_t length, ...);
#include <ason/namespace.h>
ason_t *ason_ns_read(ason_ns_t *ns, const char *text, ...);
ason_t *ason_ns_readn(ason_ns_t *ns, const char *text, size_t length,
...);
π¦ DESCRIPTION π¦
so ason_read takes an ASON value and parses it, and hands you back a whole ason_t representation of that value. main character behaviour honestly π
ason_readn? same vibe, literally identical, except it only reads length characters of the string. no cap.
then we have ason_ns_read and ason_ns_readn β they do the exact same thing but they take one extra argument, ns, which is a namespace. that namespace is where variables get evaluated from, and it's also where variables get stored. if you wanna know more about that whole situation, go read ason_namespace(3) π«Ά
π FORMAT ARGUMENTS π
okay so here's the fun part. every single one of these functions lets you pass extra arguments, and those arguments get converted into ASON values and dropped right into the appropriate spot inside the parsed value. you tell it where to put them by putting these little tokens in the string:
?iβ an integer argument. gets converted to a numeric ASON value π’?uβ an unsigned integer argument. also becomes a numeric ASON value π’?Iβ a 64-bit integer argument. numeric ASON value, but make it 64-bit πͺ?Uβ a 64-bit unsigned integer argument. yep, numeric ASON value again β?sβ a string argument. becomes an ASON string value. and yes bestie, you can absolutely use this as a key value in objects π?β anason_tvalue. used as-is, no notes, it just goes in π
π BUGS π
not me having to tell you this but β libason will try to negotiate between your current locale and the JSON-mandated UTF-8 encoding. try is the operative word. for best results, please please PLEASE just deal directly in UTF-8 π
π RETURN VALUE π
all functions should always return a valid pointer to ason_t. always. every time. slay π
π SEE ALSO π
ason(3) ason_values(3) β go read those too, they're iconic, iykyk
π AUTHOR π
Casey Dahlin <casey.dahlin@gmail.com> β thank you for your service π«‘π
and that's the whole page bestie, you're officially educated β¨ this came to you from Linux, dated JANUARY 2014, and the manual page itself is ASON_READ(3). mwah, go parse something cute ππ¦π
π¦ where this page comes from
- fedora 43: libason-devel 0.1.2-27.fc43 Β· GPL-3.0-or-later
- fedora 43: libason-devel 0.1.2-27.fc43 Β· GPL-3.0-or-later
- fedora 44: libason-devel 0.1.2-28.fc44 Β· GPL-3.0-or-later
- fedora 44: libason-devel 0.1.2-28.fc44 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms