|
Antwort |
Registriert seit: 4. Apr 2008 400 Beiträge |
#1
Hallo zusammen!
Ich möchte nach dieser Anleitung die Spritpreise analysieren: http://blog.muehlburger.at/2011/08/2...ps-entwickeln/ Die Antwort vom Server bekomme ich schon als String herrein. Nun geht es daran den String zu parsen. Da stoße ich leider auf meine Grenzen wie man das am besten löst! Kann mir da jemand helfen diesen String in ein Record oder ähnlichen zu verstauen!? Den String kann man sich einfach über den WebBrowser holen:
Code:
Antwort:
http://www.spritpreisrechner.at/espritmap-app/GasStationServlet?data=%5B%22Graz%22%2C%22DIE%22%2C15.414262484145%2C47.057105360725%2C15.494085024429%2C47.08048974931%5D
Zitat:
[{"kredit":true,"self":false,"spritPrice":[{"amount":"1.299","datAnounce":"2012-06-19 08:45:14","errorItems":[],"errorCode":0,"datValid":1340088314000,"spritId": "DIE"}],"automat":false,"city":"GRAZ","open":true,"distan ce":1.54,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.44703 13302","payMethod":" ","mail":" ","gasStationName":"Shell Austria","fax":" ","clubCard":" ","openingHours":[{"beginn":"06:00","day":{"dayLabel":"Samstag","ord er":6,"errorItems":[],"errorCode":0,"day":"SA"},"end":"23:00"},{"beginn ":"06:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"23:00"},{"beginn ":"06:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"23:00"},{"beginn ":"06:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"23:00"},{"beginn ":"06:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"23:00"},{"beginn ":"06:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"23:00"}],"access":" ","url":" ","serviceText":" ","maestro":true,"companionship":false,"address":" CONRAD V.HOETZENDORFSTR 86","club":false,"service":false,"errorCode":1,"la titude":"47.0558558312","bar":true,"telephone":"03 16825056"},{"kredit":true,"self":true,"spritPrice" :[{"amount":"1.304","datAnounce":"2012-06-18 18:54:08","errorItems":[],"errorCode":0,"datValid":1340038448000,"spritId": "DIE"}],"automat":false,"city":"Graz","open":true,"distan ce":1.37,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.46830 01","payMethod":"","mail":"zentrale@a1-tankstelle.at","gasStationName":"A1 Tankstelle Graz-Plüddemanngasse","fax":"0316 46 57 38-13","clubCard":"","openingHours":[{"beginn":"06:00","day":{"dayLabel":"Sonntag","ord er":7,"errorItems":[],"errorCode":0,"day":"SO"},"end":"22:00"},{"beginn ":"05:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"21:00"},{"beginn ":"05:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"21:00"},{"beginn ":"06:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"22:00"},{"beginn ":"05:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"21:00"},{"beginn ":"05:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"21:00"},{"beginn ":"05:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"21:00"},{"beginn ":"05:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"21:00"}],"access":"","url":"www.a1-tankstellen.at","serviceText":"","maestro":true,"c ompanionship":false,"address":"Plüddemanngasse 99","club":false,"service":false,"errorCode":1,"la titude":"47.0611267","bar":true,"telephone":"0316 46 57 38"},{"kredit":true,"self":false,"spritPrice":[{"amount":"1.314","datAnounce":"2012-06-19 08:05:16","errorItems":[],"errorCode":0,"datValid":1340085916000,"spritId": "DIE"}],"automat":false,"city":"GRAZ-ST.PETER","open":true,"distance":1.74,"postalCode" :"8042","errorItems":[],"priceSearchDisabled":false,"longitude":"15.47059 91994","payMethod":" ","mail":" ","gasStationName":"Shell Austria","fax":" ","clubCard":" ","openingHours":[{"beginn":"00:00","day":{"dayLabel":"Feiertag","or der":8,"errorItems":[],"errorCode":0,"day":"FE"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"24:00"}],"access":" ","url":" ","serviceText":" ","maestro":true,"companionship":false,"address":" ST.PETER-HAUPTSTRASSE 24","club":false,"service":false,"errorCode":1,"la titude":"47.0578504304","bar":true,"telephone":"03 16463773"},{"kredit":true,"self":true,"spritPrice" :[{"amount":"1.319","datAnounce":"2012-06-18 18:27:15","errorItems":[],"errorCode":0,"datValid":1340036835000,"spritId": "DIE"}],"automat":false,"city":"Graz","open":true,"distan ce":1.34,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.45362 279","payMethod":"Routex","mail":"R52119@bprosi.at ","gasStationName":"BP","fax":"433164654444","club Card":"","openingHours":[{"beginn":"05:00","day":{"dayLabel":"Montag","orde r":1,"errorItems":[],"errorCode":0,"day":"MO"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"24:00"},{"beginn ":"05:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"24:00"}],"access":"","url":"","serviceText":"","maestro":t rue,"companionship":false,"address":"Muenzgrabenst rasse 121 ","club":false,"service":false,"errorCode":1,"lati tude":"47.0567852","bar":true,"telephone":"4331646 5444"},{"kredit":true,"self":true,"spritPrice":[{"amount":"1.319","datAnounce":"2012-06-18 18:27:15","errorItems":[],"errorCode":0,"datValid":1340036835000,"spritId": "DIE"}],"automat":false,"city":"Graz","open":true,"distan ce":1.51,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.44821 175","payMethod":"Routex","mail":"R53638@bprosi.at ","gasStationName":"BP","fax":"433164725954","club Card":"","openingHours":[{"beginn":"06:00","day":{"dayLabel":"Samstag","ord er":6,"errorItems":[],"errorCode":0,"day":"SA"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"24:00"}],"access":"","url":"","serviceText":"Car wash sb Wäsche Staubsauger","maestro":true,"companionship":false, "address":"Froehlichgasse 45 ","club":false,"service":false,"errorCode":1,"lati tude":"47.05580667","bar":true,"telephone":"433164 72595"},{"kredit":true,"self":true,"spritPrice":[{"amount":"1.319","datAnounce":"Mon Jun 18 16:37:59 CEST 2012","errorItems":[],"errorCode":0,"datValid":1340030279000,"spritId": "DIE"}],"automat":false,"city":"Graz","open":true,"distan ce":1.99,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.45097 74","payMethod":"UTA","mail":"","gasStationName":" Turmöl","fax":"433164751524","clubCard":"","openin gHours":[{"beginn":"06:00","day":{"dayLabel":"Feiertag","or der":8,"errorItems":[],"errorCode":0,"day":"FE"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"22:00"},{"beginn ":"05:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"23:00"},{"beginn ":"05:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"23:00"},{"beginn ":"05:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"23:00"},{"beginn ":"05:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"23:00"},{"beginn ":"05:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"23:00"}],"access":"","url":"","serviceText":"Shop\r\nBistr o\r\nWaschanlage\r\nSB-Lanzenwäsche\r\nDiesel-Schnellläufer\r\n","maestro":true,"companionship": false,"address":"Conrad.-v.Hötzendorfstr. 135 ","club":false,"service":false,"errorCode":1,"lati tude":"47.0510643","bar":true,"telephone":"4331647 5152"},{"kredit":true,"self":true,"spritPrice":[{"amount":"","datAnounce":"","errorItems":[],"errorCode":0,"datValid":0,"spritId":""}],"automat":false,"city":"Graz","open":true,"distan ce":1.98,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.44314 99","payMethod":"ROTH VorteilsCard ROTH BusinessCard Flottenkarte Accor Sodexo Lyoness GrazGutschein","mail":"","gasStationName":"ROTH Kasernstrasse","fax":"43316466095","clubCard":""," openingHours":[{"beginn":"06:00","day":{"dayLabel":"Freitag","ord er":5,"errorItems":[],"errorCode":0,"day":"FR"},"end":"21:00"},{"beginn ":"06:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"21:00"},{"beginn ":"06:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"21:00"},{"beginn ":"06:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"21:00"},{"beginn ":"07:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"20:00"},{"beginn ":"07:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"20:00"},{"beginn ":"06:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"20:00"},{"beginn ":"06:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"21:00"}],"access":"","url":"www.roth.at","serviceText":"Sh op Heizoelverkauf","maestro":true,"companionship":fal se,"address":"Kasernstrasse 14","club":true,"service":true,"errorCode":1,"lati tude":"47.052687","bar":true,"telephone":"43316472 276"},{"kredit":true,"self":true,"spritPrice":[{"amount":"","datAnounce":"","errorItems":[],"errorCode":0,"datValid":0,"spritId":""}],"automat":false,"city":"Graz","open":true,"distan ce":1.13,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.46176 ","payMethod":"Kundenkarte Businesskarte Flottenkarte Lieferschein","mail":"PSAT393802@ris.molaustria.at ","gasStationName":"MOL Elisabethstraße","fax":"4331632312114","clubCard": "MOL","openingHours":[{"beginn":"00:00","day":{"dayLabel":"Samstag","ord er":6,"errorItems":[],"errorCode":0,"day":"SA"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"24:00"},{"beginn ":"00:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"24:00"}],"access":"","url":"www.mol.at","serviceText":"Sho p Bistro Waschanlage Freiwaschplatz Staubsauger Autopflege ","maestro":true,"companionship":false,"address":" Elisabethstraße 78","club":true,"service":false,"errorCode":1,"lat itude":"47.0775241","bar":true,"telephone":"433163 23121"},{"kredit":true,"self":true,"spritPrice":[{"amount":"","datAnounce":"","errorItems":[],"errorCode":0,"datValid":0,"spritId":""}],"automat":false,"city":"Graz","open":true,"distan ce":1.01,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.45904 ","payMethod":"UTA, OMV STATIONSKARTE, AMEX, DINERS, MAESTRO, MASTERCARD, ROUTEX, VISA","mail":"retail.at.1607@omv.com","gasStationN ame":"OMV - Graz Seebacher Gasse","fax":"31632538513","clubCard":"","openingH ours":[{"beginn":"06:00","day":{"dayLabel":"Freitag","ord er":5,"errorItems":[],"errorCode":0,"day":"FR"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Mittwoch","order":3," errorItems":[],"errorCode":0,"day":"MI"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"24:00"},{"beginn ":"06:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"24:00"}],"access":"","url":"www.omv.com","serviceText":"", "maestro":true,"companionship":false,"address":"Se ebacher Gasse 8","club":false,"service":true,"errorCode":1,"lati tude":"47.07722","bar":true,"telephone":"316325385 "},{"kredit":true,"self":true,"spritPrice":[{"amount":"","datAnounce":"","errorItems":[],"errorCode":0,"datValid":0,"spritId":""}],"automat":false,"city":"Graz","open":true,"distan ce":1.44,"postalCode":"8010","errorItems":[],"priceSearchDisabled":false,"longitude":"15.45404 ","payMethod":"UTA, OMV STATIONSKARTE, AMEX, DINERS, MAESTRO, MASTERCARD, ROUTEX, VISA","mail":"retail.at.1723@omv.com","gasStationN ame":"OMV - Graz Heinrichstraße 91","fax":"31632315113","clubCard":"","openingHour s":[{"beginn":"06:00","day":{"dayLabel":"Mittwoch","or der":3,"errorItems":[],"errorCode":0,"day":"MI"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Dienstag","order":2," errorItems":[],"errorCode":0,"day":"DI"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Freitag","order":5,"e rrorItems":[],"errorCode":0,"day":"FR"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Sonntag","order":7,"e rrorItems":[],"errorCode":0,"day":"SO"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Samstag","order":6,"e rrorItems":[],"errorCode":0,"day":"SA"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Feiertag","order":8," errorItems":[],"errorCode":0,"day":"FE"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Donnerstag","order":4 ,"errorItems":[],"errorCode":0,"day":"DO"},"end":"22:00"},{"beginn ":"06:00","day":{"dayLabel":"Montag","order":1,"er rorItems":[],"errorCode":0,"day":"MO"},"end":"22:00"}],"access":"","url":"www.omv.com","serviceText":"", "maestro":true,"companionship":false,"address":"He inrichstrasse 91","club":false,"service":true,"errorCode":1,"lat itude":"47.08178","bar":true,"telephone":"31632315 1"}]
Delphi 2010, Update 4 & 5
|
Zitat |
Registriert seit: 20. Jan 2006 Ort: Lübbecke 11.475 Beiträge Delphi 12 Athens |
#2
Sieht sehr nach JSON aus. In deinem Delphi müsste schon ein passender Parser vorhanden sein.
|
Zitat |
Registriert seit: 4. Apr 2008 400 Beiträge |
#3
Sieht sehr nach JSON aus. In deinem Delphi müsste schon ein passender Parser vorhanden sein.
Ja, JSON String wird in der Homepage erwähnt. Habe mir nur nichts dabei gedacht da ich JSON bis jetzt icht kannte! Wenn ich den String hier durch schicke kommt was raus was Sinn macht: http://chris.photobooks.com/json/default.htm
Delphi 2010, Update 4 & 5
|
Zitat |
Registriert seit: 4. Apr 2008 400 Beiträge |
#4
Jetzt habe ich aber doch noch Probleme den JSON String auszuwerten.
1. ich muss vorne und hinten die Klammern '[' & ']' entfernen: data := MidStr(data, 2, Length(data) - 1); 2. danach lade ich es in das ISuperObject obj := SO(data); 3. ich bekomme nun ein ISuperObject das ich auch auswerten kann. Jedoch weis ich jetzt nicht wie ich auf die einzelnen "root" Elemente zugreifen kann Wenn ich es so mache:
Delphi-Quellcode:
Dann bekomme ich immer sozusagen root[0]. Wie komme ich aber auf root[0..9]?
obj1 := obj.AsObject.O['spritPrice'];
tmpstr:= obj1.AsString; // Klammern vorne und hinten entfernen tmpstr:= MidStr(tmpstr, 2, Length(tmpstr) - 1); obj1 := SO(tmpstr); Spritpreis := obj1.AsObject.S['amount'];
Delphi 2010, Update 4 & 5
|
Zitat |
Registriert seit: 11. Okt 2003 Ort: Elbflorenz 44.184 Beiträge Delphi 12 Athens |
#5
Das ganze ich ein JSON-Array und das sollte man auch als solches Parsen/Einlesen.
[Wert,Wert,...] = Array {"property":Wert,"property":Wert} = Object Wert = z.B. Integer, "String", Boolean (TRUE oder FALSE), [Array], {Objekt} usw. Meistens wird als Root-Element ein Objekt verwendet und du wirst es bestimmt auch so versuchen auszulesen? Es gibt immer nur ein Root-Element! Wenn du die Array-Kennung ("[" und "]") wegläßt, dann wird nur der erste Wert eingelesen und danach natürlich aufgehört. Also entweder als Array einlesen, oder probiers mal mit '{"root"=' + s + '}' zu umschließen.
$2B or not $2B
Geändert von himitsu (19. Jun 2012 um 12:19 Uhr) |
Zitat |
Registriert seit: 11. Apr 2005 Ort: Darmstadt 148 Beiträge Delphi XE2 Enterprise |
#6
Jetzt habe ich aber doch noch Probleme den JSON String auszuwerten.
1. ich muss vorne und hinten die Klammern '[' & ']' entfernen: data := MidStr(data, 2, Length(data) - 1);
Delphi-Quellcode:
obj1 := obj.AsObject.O['spritPrice'];
tmpstr:= obj1.AsString; // Klammern vorne und hinten entfernen tmpstr:= MidStr(tmpstr, 2, Length(tmpstr) - 1); obj1 := SO(tmpstr); Spritpreis := obj1.AsObject.S['amount'];
Delphi-Quellcode:
var
iter: TSuperObjectIter; spData: ISuperObject; begin spData := SO(data); if ObjectFindFirst(spData, iter) then begin repeat // Hier hast du Zugriff auf die einzelnen Array-Einträge: Writeln(iter.val.AsJson(true)); until not ObjectFindNext(iter); ObjectFindClose(iter); end; end; |
Zitat |
Registriert seit: 4. Apr 2008 400 Beiträge |
#7
Danke!
Mit dem AsArray kann ich nun auf alle Werte zugreifen. Habe vorher nicht verstanden, dass die [..] ein Array bedeuten. Nun hätte ich noch eine kleine Formatierungs Frage dazu: Die Werte geben auch eine Uhrzeit mit wann das letzte mal die Daten aktualisiert worden sind: 1. 2012-06-19 09:28:16 2. Tue Jun 19 12:02:22 CEST 2012 Im ersten Format habe ich keine Probleme damit weiter zu arbeiten. Jedoch muss ich das Format von der zweiten Variante in das gleiche Format wie in Variante 1 bringen. Leider schlagen meine Versuche fehl:
Delphi-Quellcode:
DTFormat.TimeSeparator := ':';
DTFormat.DateSeparator := ' '; DTFormat.ShortDateFormat := 'ddd mmm d hh:nn:ss yyyy'; DTFormat.LongDateFormat := 'ddd mmm d hh:nn:ss yyyy'; myDateTime := StrToDateTime(datAnounce, DTFormat);
Delphi 2010, Update 4 & 5
|
Zitat |
Registriert seit: 11. Okt 2003 Ort: Elbflorenz 44.184 Beiträge Delphi 12 Athens |
#8
StrToDateTime/StrToDate/StrToTime sind schrecklich implementiert und können nicht alle Formate lesen, da selten garnicht der FormatString zur Interpretation herangezogen wird.
(dazu sollte es irgendwo, die letzen 3-12 Monate, einen Thread von mir geben) Dein Delphi ist doch bestimmt auf deutsch installiert/eingestellt? Wenn ja, dann sind die Monats- und Wochentags-Strings natürlich auch in deutsch geladen. Selbst wenn es mit StrToDateTime funktioniert ... mit den falschen Strings kann das schlecht erkannt/übersetzt werden. DTFormat.ShortMonthNames DTFormat.LongMonthNames DTFormat.ShortDayNames DTFormat.LongDayNames
$2B or not $2B
|
Zitat |
Ansicht |
Linear-Darstellung |
Zur Hybrid-Darstellung wechseln |
Zur Baum-Darstellung wechseln |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
LinkBack URL |
About LinkBacks |