A quick immediate mode json proof of concept inspired by Tsoding's Jim Library
This uses:
This doesn't support formatting, and could use better guardrails (or a better API) around accidentally writing kv pairs into arrays, or accidentally writing array values into objects.
Usage:
#include "imjson.c"
#include <stdio.h>
int
main()
{
enum { BufLn = 10000 };
char Buf[BufLn] = {0};
ij_ctx JsonCtx = IJ_CtxNew(Buf, BufLn);
ij_ctx *C = &JsonCtx;
IJ_Obj(C, "")
{
IJ_Num(C, "test", 123);
IJ_Arr(C, "heyo")
{
IJ_Float(C, "", 3.14);
IJ_Double(C, "", 3.141592653589);
IJ_SNum(C, "", -100);
IJ_Null(C, "");
IJ_Bool(C, "", true);
}
}
printf(Buf);
return 0;
}