Annotation of libelwix/example/test_valid.c, revision 1.1.2.4
1.1.2.1 misho 1: #include <stdio.h>
2: #include <elwix.h>
3:
4:
5: int
6: main(int argc, char **argv)
7: {
1.1.2.4 ! misho 8: int pos = 0, started = 0;
! 9: char line[BUFSIZ] = { 0 }, str[BUFSIZ] = { 0 }, str2[BUFSIZ];
! 10: json_t json;
1.1.2.2 misho 11:
1.1.2.4 ! misho 12: if (argc > 1) {
! 13: printf("validate=%d\n", json_validate(argv[1], &started));
! 14: printf("started=%d\n", started);
! 15: }
1.1.2.1 misho 16:
1.1.2.4 ! misho 17: printf("Input test JSON for marshaling> ");
! 18: while (!feof(stdin)) {
! 19: fgets(line, sizeof line - 1, stdin);
! 20: strlcat(str, line, sizeof str);
! 21:
! 22: if (json_validate(str, &started))
! 23: break;
! 24: }
! 25: strlcpy(str2, str, sizeof str2);
! 26:
! 27: json_init(&json, 0);
! 28: printf("json_parse num tokens=%d\n", json_parse(&json, str, sizeof str, NULL, 0));
! 29: json_free(&json);
! 30:
! 31: if (json_marshaling(str, 0))
! 32: printf("Marshaled JSON with spaces> %s\n", str);
! 33: if (json_marshaling(str2, 1))
! 34: printf("Marshaled JSON> %s\n", str2);
1.1.2.1 misho 35: return 0;
36: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>