-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
15 lines (14 loc) · 714 Bytes
/
example.c
File metadata and controls
15 lines (14 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <mgc/json/json.h>
int main(int argc, char* argv[]) {
char* raw = "{ \"taco\" : \"tuesday\", \"toppings\": [ \"lettuce\", \"onions\", \"salsa\"], \"otra vez\": { \"tortilla\": \"con salsa\" } }";
JSON* as_json = toJSON(raw);
printJSON(as_json);
char* as_str = JSONtoString(as_json);
JSON* member = getJSONElementByName(as_json, "toppings");
JSON* element = getJSONArrayElementByIndex(member, 1);
printf("_[toppings][1]=%s\n", JSONtoString(element));
member = getJSONElementByName(as_json, "otra vez");
element = getJSONElementByName(member, "tortilla");
printf("%s\n", JSONtoString(element));
return 0;
}