Temat: jshn - parse json package
Hej,
pytanko ws json. W openwrt domyślnie jest pod ręką jshn. Ściągam sobie z internetu pogodę w formacie json. Następnie chcę wyfiltorwać tylko temperaturę oraz wiatr. Całość zrobiłem w ten sposób:
wget "api.openweathermap.org/data/2.5/weather?id=2172797&appid=44db6a862fba0b067b1930da0d769e98"
$pogoda=`cat weather?`
jshn -r "$pogoda"
Wyświetla się:
json_init;
json_add_object 'coord';
json_add_double 'lon' 18.650000;
json_add_double 'lat' 50.300000;
json_close_object;
json_add_array 'weather';
json_add_object '0';
json_add_int 'id' 701;
json_add_string 'main' 'Mist';
json_add_string 'description' 'mist';
json_add_string 'icon' '50n';
json_close_object;
json_close_array;
json_add_string 'base' 'cmc stations';
json_add_object 'main';
json_add_double 'temp' 262.900000;
json_add_int 'pressure' 1033;
json_add_int 'humidity' 92;
json_add_double 'temp_min' 261.150000;
json_add_double 'temp_max' 263.750000;
json_close_object;
json_add_object 'wind';
json_add_double 'speed' 3.100000;
json_add_int 'deg' 140;
json_close_object;
json_add_object 'snow';
json_close_object;
json_add_object 'clouds';
json_add_int 'all' 0;
json_close_object;
json_add_int 'dt' 1453490267;
json_add_object 'sys';
json_add_int 'type' 3;
json_add_int 'id' 5356;
json_add_double 'message' 0.010000;
json_add_string 'country' 'PL';
json_add_int 'sunrise' 1453444351;
json_add_int 'sunset' 1453476124;
json_close_object;
json_add_int 'id' 7530857;
json_add_string 'name' 'Gliwice';
json_add_int 'cod' 200;Nie wiem jak zrobic, aby przy uzyciu jshn pokazac wartość danej lini np.: dla speed byłaby to wartość: 3.100000
wrt podpowiada: Usage: jshn [-n] -r <message>|-w
Niestety nie rozumiem jak to mogę łatwo wyfiltorwać. Atrybut: |-w nie działa.