jansson #5
@ -92,15 +92,24 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (res.body[i] == '\n') {
|
||||
if (lastWasNewline) {
|
||||
printf("Headers end at: %i\n", i);
|
||||
|
||||
int rBL = resBodyLength - i;
|
||||
char* body = malloc(rBL);
|
||||
for (int j = 0; j < rBL; j++) {
|
||||
body[j] = res.body[j + i + 1];
|
||||
}
|
||||
|
||||
printf("\"%s\"\n", body);
|
||||
json_error_t error;
|
||||
json_t *root = json_loads(body, 0, &error);
|
||||
if (!root || !json_is_array(root)) {
|
||||
printf("failed decoding\n");
|
||||
}
|
||||
else {
|
||||
printf("%s\n", body);
|
||||
for (int j = 0; j < json_array_size(root); j++) {
|
||||
json_t *data = json_array_get(root, j);
|
||||
printf("%s\n", json_string_value(data));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user