Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 454 Bytes

File metadata and controls

19 lines (16 loc) · 454 Bytes

json

a character-by-character JSON parser.

example

struct json parser = {};
enum json_state stack[3] = {};
json_init(&parser, stack, sizeof(stack));

char *json = "{\"Hello\": \"world!\"}";
for(char *i = json; *i != '\0'; i++)
{
	enum json_state state = json_parse(&parser, *i);
	printf("state: %s\n", json_state_name(state));
}

enum json_state state = json_peek(&parser);
printf("%s JSON!\n", state == VALID ? "VALID" : "INVALID");