You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I receive a json object, wich has several informations and also an array of interfaces wuth several informations for each of them.
The array can be of any size (from one element to 4, 5 or even 6 elements).
You need the name of the interface in the json_scanf_array_elem call.
Something like json_scanf_array_elem(str, len, ".enp7s0f1", i, &t), supposing you call json_scanf(buf, strlen(buf), "{ports:[%M]}", scan_array2, NULL);
I receive a json object, wich has several informations and also an array of interfaces wuth several informations for each of them.
The array can be of any size (from one element to 4, 5 or even 6 elements).
The json is this:
{"status": "1", "message": "No Errors", "channel": "TEST", "writes": "481725079297", "cpu": "1.22", "memory": "403440", "ports": {"enp7s0f1": [{"byteIn": "118585715528669","byteOut": "1094749498510","packetIn": "78618393261","packetOut": "8078419574"}],"enp6s0f1": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp3s0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp7s0f0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp6s0f0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"lo": [{"byteIn": "1532650647","byteOut": "1532650647","packetIn": "5444282","packetOut": "544428"}]}}
I need to parse the ports array.
So, I did this way:
static void scan_array2(const char *str, int len, void *user_data) {
struct json_token t;
int i;
float bytein;
}
The result is:
status: 1
message: No Errors
channel: TEST
writes: 481725079297
cpu: 1.22
mem: 403440
Parsing array: {"enp7s0f1": [{"byteIn": "118585715528669","byteOut": "1094749498510","packetIn": "78618393261","packetOut": "8078419574"}],"enp6s0f1": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp3s0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp7s0f0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"enp6s0f0": [{"byteIn": "0","byteOut": "0","packetIn": "0","packetOut": "0"}],"lo": [{"byteIn": "1532650647","byteOut": "1532650647","packetIn": "5444282","packetOut": "544428"}]}
It doesn't parse the array, even entering the method scan_array2.
Can you help to find how thi scan be done? The examples are not clear, for me.
Thnaks
The text was updated successfully, but these errors were encountered: