ref: c4ef9e2925f8baec22d6737872326736b31bf45f
parent: c5dfca354a35575443084622a74de02ef3e6ea8e
author: sirjofri <sirjofri@sirjofri.de>
date: Sat Mar 7 18:38:27 EST 2026
adds readme
--- /dev/null
+++ b/README
@@ -1,0 +1,61 @@
+Reflective JSON wrapper library
+
+To convert between structs and json easily.
+
+
+EXAMPLE
+
+---snip---
+#include <json.h>
+#include "rjson.h"
+
+typedef struct Vector Vector;
+struct Vector {+ double x;
+ double y;
+ double z;
+};
+
+RJSON_BEGIN(RVector_defs)
+ RJSON_NUMBER(Vector,x)
+ RJSON_NUMBER(Vector,y)
+ RJSON_NUMBER(Vector,z)
+RJSON_END()
+
+typedef struct Poi Poi;
+struct Poi {+ char *label;
+ double priority;
+ Vector pos;
+};
+
+RJSON_BEGIN(RPoi_defs)
+ RJSON_STRING(Poi,label)
+ RJSON_NUMBER(Poi,priority)
+ RJSON_OBJECT(Poi,pos, RVector_defs)
+RJSON_END()
+
+/* Rjson* are RVector_defs and RPoi_defs */
+/* void-pointers are pointers to the structures in question */
+int rjsontostruct(JSON*, Rjson*, void*);
+JSON *rstructtojson(void*, Rjson*);
+---snap---
+
+See the test/t.c file for a working example.
+
+
+SUPPORTED TYPES
+
+RJSON_STRING(Struct,Name)
+RJSON_NUMBER(Struct,Name)
+RJSON_BOOL(Struct,Name)
+RJSON_OBJECT(Struct,Name, Subobject_defs)
+
+
+IMPORTANT
+
+→ char* members are malloc'd strings.
+→ the name in the macros mustn't start with a space character.
+→ there's currently no array support
+→ there should be no leaks
+→ there are probably bugs
--
⑨