-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
65 lines (55 loc) · 1.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "common.h"
int main()
{
char *json = get_json_file_content("dev.json");
int size = strlen(json);
int index = 0;
JsonValue *value = match_any(json, &index, size);
printf("----------------------------\n");
if (value->error != NULL)
{
printf("ERROR\n");
printf("code = %s\n", value->error->code);
printf("at index= %d\n", value->error->index);
}
else
{
printf("SUCCESS\n");
printf("type = %d\n", value->type);
printf("start = %d\n", value->start);
printf("end = %d\n", value->end);
switch (value->type)
{
case JSON_NUMBER:
printf("number = %f\n", value->number);
break;
case JSON_STRING:
printf("string = %s\n", value->string);
break;
case JSON_FALSE:
printf("boolean = %s\n", "false");
break;
case JSON_TRUE:
printf("boolean = %s\n", "true");
break;
case JSON_NULL:
printf("null = %s\n", "null");
break;
case JSON_ARRAY:
printf("array length = %d\n", value->array->size);
break;
case JSON_OBJECT:
printf("object length = %d\n", value->object->count);
break;
default:
break;
}
}
printf("----------------------------\n");
free_json_value(value);
free(json);
return 0;
}