shithub: rjson

ref: c5dfca354a35575443084622a74de02ef3e6ea8e
dir: /rjson.h/

View raw version
#define RJSON_BEGIN(A) Rjson A[] = {
#define RJSON_END() { 0, 0, nil }};
#define RJSON_STRING(A, N) { offsetof(A, N), JSONString, "N", nil },
#define RJSON_NUMBER(A, N) { offsetof(A, N), JSONNumber, "N", nil },
#define RJSON_BOOL(A, N) { offsetof(A, N), JSONBool, "N", nil },
#define RJSON_OBJECT(A, N, S) { offsetof(A, N), JSONObject, "N", S },

typedef struct Rjson Rjson;
struct Rjson {
	int addr;
	int type;
	char *name;
	Rjson *sub;
};

int rjsontostruct(JSON *json, Rjson*, void*);
JSON *rstructtojson(void *src, Rjson*);