S
Das war der entscheidende Tip aber musste:
const json_object *pos_jso;
auf:
struct json_object *pos_jso;
ändern, dass das geht, hatte gestern Abend mir eine Umständliche Lösung gebaut und kam darauf:
#include <stdio.h>
#include <json-c/json.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
int sn_pos;
char sn_id[12];
int sn_update;
char sn_file_size[12];
int sn_active;
} sort_sn;
int sn_sort( const void *left, const void *right ) {
const sort_sn *b = ( const sort_sn *)left;
const sort_sn *a = ( const sort_sn *)right;
if (b->sn_pos < a->sn_pos) {
return -1;
} else if (a->sn_pos < b->sn_pos) {
return 1;
} else {
return (a->sn_id < b->sn_id) - (b->sn_id < a->sn_id);
}
}
int main(int argc, char const *argv[]) {
json_object *JSON_FILE = json_object_from_file("./Config.json");
json_object *LIST = json_object_object_get(JSON_FILE, "LIST");
size_t LIST_Len = json_object_array_length(LIST);
sort_sn meineDatenArray[LIST_Len];
for (int a = 0; a < LIST_Len; a++) {
json_object *OBJ = json_object_array_get_idx(LIST, a);
json_object *ID = json_object_object_get(OBJ, "ID");
json_object *POS = json_object_object_get(OBJ, "POS");
json_object *UPDATE = json_object_object_get(OBJ, "UPDATE");
json_object *FILE_SIZE = json_object_object_get(OBJ, "FILE_SIZE");
json_object *IS_ACTIVE = json_object_object_get(OBJ, "IS_ACTIVE");
meineDatenArray[a].sn_pos = json_object_get_int(POS);
strcpy(meineDatenArray[a].sn_id, json_object_get_string(ID));
meineDatenArray[a].sn_update = json_object_get_int(UPDATE);
strcpy(meineDatenArray[a].sn_file_size, json_object_get_string(FILE_SIZE));
meineDatenArray[a].sn_active = json_object_get_int(IS_ACTIVE);
}
qsort(meineDatenArray, LIST_Len, sizeof(sort_sn), sn_sort);
for (size_t i = 0; i < LIST_Len; i++) {
printf( "%d, %s, %s\n", meineDatenArray[i].sn_pos, meineDatenArray[i].sn_id, meineDatenArray[i].sn_title );
}
return 0;
}
Natürlich ist der Weg weit aus länger aber war mein Gedanke mal anders anzugehen.
Wie gesagt, Dank dir für die Hilfe