ASON_READ(3)

πŸ“¦ version 0.1.2, in fedora 43, fedora 44

πŸ’– 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 πŸ”‘
  • ? β€” an ason_t value. 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