Hallo!
Zuerst: lieben Dank für deine Arbeit, hatte ich auch schon lange gesucht und nicht den geringsten Ansatz:
Meinem Vorschreiber möchte ich mich anschließen. Ich habe deine Scriptzeilen studiert, ich denke teilweise behirnt, bin aber unfähig irgendwas funktionales anzupassen. Dafür hab mich mal an das Zerlegen der JSON gemacht und folgendes festgestellt:
- Die Daten kommen schon vorsortiert von 1 -10 (Datenpunkt "position"), hießt man bräuchte "nur" auslesen und in Datenpunkte wegschreiben.
Das Blöde ist nur, der Datenpunkt "position" ist erst kurz vor "amount" und der Namen, sowie die Adresse der Tankstelle einige Datenpunkte davor.
Mich würden z.B. auch nur die ersten 5 Treffer interessieren. Ich habe nur 0 Ahnung wie man im Javascript um paar Werte nach vone springt?
if (gasStation[index].position== "1") {
*jetzt hüpfe zurück auf das nächste Feld "name" und liefere mir den namen und die Adresse, dann geh weiter runter und liefere mir:*
price = (gasStation[index].prices[0].amount).toString().replace(".",",");
}
Als Ergebnis würde ich mir zu füllende Datenpunkte wünschen wie
setState("javascript.0.Aktueller_Spritpreis_Hit_01"/*Aktueller Spritpreis*/, open, name, location/adress, amount,);
setState("javascript.0.Aktueller_Spritpreis_Hit_02"/*Aktueller Spritpreis*/, open, name, location/adress, amount,);
setState("javascript.0.Aktueller_Spritpreis_Hit_03"/*Aktueller Spritpreis*/, open, name, location/adress, amount,);
*...... bis 05*
Die JSON Ausgabe sieht bei mir so aus:
[{"id":4308,"name":"Diskont Tankstelle","location":{"address":"Breitenfurter Strasse 261 (\"Hofer-Parkplatz\")","postalCode":"1230","city":"Wien","latitude":48.1506803,"longitude":16.3016662},"contact":{"telephone":"43800202055","mail":"office@fe-trading.at","website":"http://www.diskonttanken.at/"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"06:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":true},"paymentMethods":{"cash":false,"debitCard":true,"creditCard":true,"others":"DKV-Card"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":1,"open":true,"distance":3.5753605966901376,"prices":[{"fuelType":"DIE","amount":1.156,"label":"Diesel"}]},{"id":33381,"name":"A1 Tankstelle Wien-Endresstraße","location":{"address":"Endresstraße 69","postalCode":"1230","city":"Wien","latitude":48.1486138,"longitude":16.2777595},"contact":{"telephone":"4318860846","fax":"4318860913","mail":"zentrale@a1-tankstellen.at","website":"http://www.a1-tankstellen.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"21:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"21:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"UTA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":2,"open":true,"distance":1.9218480976993273,"prices":[{"fuelType":"DIE","amount":1.161,"label":"Diesel"}]},{"id":1354794,"name":"JET TANKSTELLE","location":{"address":"KETZERGASSE 208","postalCode":"1230","city":"WIEN","latitude":48.130709,"longitude":16.289516},"contact":{"telephone":"018650713"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"05:30","to":"23:30"},{"day":"DI","label":"Dienstag","order":2,"from":"05:30","to":"23:30"},{"day":"MI","label":"Mittwoch","order":3,"from":"05:30","to":"23:30"},{"day":"DO","label":"Donnerstag","order":4,"from":"05:30","to":"23:30"},{"day":"FR","label":"Freitag","order":5,"from":"05:30","to":"23:30"},{"day":"SA","label":"Samstag","order":6,"from":"05:30","to":"23:30"},{"day":"SO","label":"Sonntag","order":7,"from":"05:30","to":"23:30"},{"day":"FE","label":"Feiertag","order":8,"from":"05:30","to":"23:30"}],"offerInformation":{"service":false,"selfService":true,"unattended":true},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true},"paymentArrangements":{"cooperative":false,"clubCard":false},"otherServiceOffers":"Autowäsche, Billa shop & shop, Backshop, Vignetten-Verkauf","position":3,"open":true,"distance":2.5037988374142626,"prices":[{"fuelType":"DIE","amount":1.161,"label":"Diesel"}]},{"id":33395,"name":"A1 Tankstelle Perchtoldsdorf","location":{"address":"Ketzergasse 191a","postalCode":"2380","city":"Perchtoldsdorf","latitude":48.1301731,"longitude":16.2919418},"contact":{"telephone":"4318674570","fax":"4318674804","mail":"zentrale@a1-tankstellen.at","website":"http://www.a1-tankstellen.at/"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"07:00","to":"21:00"},{"day":"FE","label":"Feiertag","order":8,"from":"07:00","to":"21:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"UTA, DKV"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":4,"open":true,"distance":2.693645361693586,"prices":[{"fuelType":"DIE","amount":1.161,"label":"Diesel"}]},{"id":1038190,"name":"Turmöl","location":{"address":"Breitenfurterstrasse 473","postalCode":"1230","city":"Wien","latitude":48.1378231,"longitude":16.257528},"contact":{"telephone":"4318860647","website":"http://www.doppler.at"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"06:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":5,"open":true,"distance":0.0019099423292094483,"prices":[{"fuelType":"DIE","amount":1.163,"label":"Diesel"}]},{"id":1354893,"name":"OMV - Wien Speisinger Straße 228","location":{"address":"Speisinger Strasse 228","postalCode":"1232","city":"Wien","latitude":48.15489,"longitude":16.2711},"contact":{"telephone":"18887229","fax":"1888722913","mail":"retail.at.7505@omv.com","website":"www.omv.com"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:30","to":"21:00"},{"day":"SO","label":"Sonntag","order":7,"from":"06:30","to":"21:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:30","to":"21:00"}],"offerInformation":{"service":true,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"OMV STATIONSKARTE, ENI Routex Card, OMV ROUTEX, STATOIL card, BP card, MASTERCARD, MAESTRO, DINERS, VISA, AMEX"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":6,"open":true,"distance":2.1487569498351693,"prices":[]},{"id":247975,"name":"eni","location":{"address":"Breitenfurter Str. 325-327","postalCode":"1230","city":"Wien","latitude":48.14312,"longitude":16.29248},"contact":{"telephone":"018690303","fax":"018657360"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"06:00","to":"22:00"},{"day":"SO","label":"Sonntag","order":7,"from":"06:00","to":"22:00"},{"day":"FE","label":"Feiertag","order":8,"from":"06:00","to":"22:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"AMEX,Maestro,Diners Club,DKV,GUTS,MasterCard,Routex,UTA,VISA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":7,"open":true,"distance":2.6607127321589514,"prices":[]},{"id":1354920,"name":"OMV - Wien Brunner Straße 77-79","location":{"address":"Brunner Strasse 77-79","postalCode":"1230","city":"Wien","latitude":48.13342,"longitude":16.29849},"contact":{"telephone":"18695856","fax":"1869585613","mail":"retail.at.7554@omv.com","website":"www.omv.com"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"00:00","to":"24:00"},{"day":"DI","label":"Dienstag","order":2,"from":"00:00","to":"24:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"00:00","to":"24:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"00:00","to":"24:00"},{"day":"FR","label":"Freitag","order":5,"from":"00:00","to":"24:00"},{"day":"SA","label":"Samstag","order":6,"from":"00:00","to":"24:00"},{"day":"SO","label":"Sonntag","order":7,"from":"00:00","to":"24:00"},{"day":"FE","label":"Feiertag","order":8,"from":"00:00","to":"24:00"}],"offerInformation":{"service":true,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"UTA, ENI Routex Card, OMV ROUTEX, STATOIL card, BP card, MASTERCARD, MAESTRO, DINERS, VISA, AMEX, OMV STATIONSKARTE"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":8,"open":true,"distance":3.080965956484636,"prices":[]},{"id":247819,"name":"eni","location":{"address":"Feldstraße 44","postalCode":"2345","city":"Brunn/Geb.","latitude":48.122997,"longitude":16.293216},"contact":{"telephone":"02236378873","fax":"0223637887313"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"00:00","to":"24:00"},{"day":"DI","label":"Dienstag","order":2,"from":"00:00","to":"24:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"00:00","to":"24:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"00:00","to":"24:00"},{"day":"FR","label":"Freitag","order":5,"from":"00:00","to":"24:00"},{"day":"SA","label":"Samstag","order":6,"from":"00:00","to":"24:00"},{"day":"SO","label":"Sonntag","order":7,"from":"00:00","to":"24:00"},{"day":"FE","label":"Feiertag","order":8,"from":"00:00","to":"24:00"}],"offerInformation":{"service":false,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"AMEX,Maestro,Diners Club,DKV,GUTS,MasterCard,Routex,UTA,VISA"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":9,"open":true,"distance":3.1223737662403592,"prices":[]},{"id":423,"name":"OMV - Perchtoldsdorf Brunner Gasse 48","location":{"address":"Brunner Gasse 48","postalCode":"2380","city":"Perchtoldsdorf","latitude":48.11554,"longitude":16.27169},"contact":{"telephone":"18691300","fax":"1869130013","mail":"retail.at.8536@omv.com","website":"www.omv.com"},"openingHours":[{"day":"MO","label":"Montag","order":1,"from":"06:00","to":"22:00"},{"day":"DI","label":"Dienstag","order":2,"from":"06:00","to":"22:00"},{"day":"MI","label":"Mittwoch","order":3,"from":"06:00","to":"22:00"},{"day":"DO","label":"Donnerstag","order":4,"from":"06:00","to":"22:00"},{"day":"FR","label":"Freitag","order":5,"from":"06:00","to":"22:00"},{"day":"SA","label":"Samstag","order":6,"from":"07:00","to":"20:00"},{"day":"SO","label":"Sonntag","order":7,"from":"08:00","to":"20:00"},{"day":"FE","label":"Feiertag","order":8,"from":"08:00","to":"20:00"}],"offerInformation":{"service":true,"selfService":true,"unattended":false},"paymentMethods":{"cash":true,"debitCard":true,"creditCard":true,"others":"OMV STATIONSKARTE, ENI Routex Card, OMV ROUTEX, STATOIL card, BP card, MASTERCARD, MAESTRO, DINERS, VISA, AMEX"},"paymentArrangements":{"cooperative":false,"clubCard":false},"position":10,"open":true,"distance":2.6945233440437857,"prices":[]}]
Kann mir da bitte jemand weiterhlefen?
LG und Danke im Voraus, mxa