Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Wert aus json

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Wert aus json

    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kaspaani last edited by

      Hallo und Frohe Weihnachten

      Ich bin neu hier und habe noch nicht viel Erfahrung mit Blocky etc. Ich habe ein Problem einen Wert aus ein JSON heraus zu bekommen. Ich habe folgende JSON und möchte den 5 Wert: quantity als Variable separieren.44912977-f414-412d-9f5f-dced270e46d3-image.png
      Als Ansatz habe ich diesen:Blocky.JPG

      Leider funktioniert es nicht. Kann mir jemand hierbei helfen? Ich bekomme immer die Fehlermeldung:
      10:18:01.307 info javascript.0 (10450) script.js.Ladeleistung: undefined

      Ob ich bei Wert die Position oder den Namen "quantity" eingebe bleibt alles gleich.
      Wäre schön wenn mir jemand helfen würde.
      Gruß

      mickym Homoran paul53 3 Replies Last reply Reply Quote 0
      • mickym
        mickym Most Active @Kaspaani last edited by

        @kaspaani Probier mal:

        Wert[0].quantity
        

        als Attribut.

        K 1 Reply Last reply Reply Quote 0
        • K
          Kaspaani @mickym last edited by

          @mickym Leider gleiche Meldung.

          liv-in-sky mickym 2 Replies Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @Kaspaani last edited by liv-in-sky

            @kaspaani

            du musst das label in quantity ändern und deinen dp einsetzen

            Image 095.png

            K 1 Reply Last reply Reply Quote 0
            • mickym
              mickym Most Active @Kaspaani last edited by mickym

              Gelöscht

              1 Reply Last reply Reply Quote 0
              • K
                Kaspaani @liv-in-sky last edited by

                @liv-in-sky Hallo ich hoffe ich habe es richtig umgesetzt. Sieht jetzt so aus.
                cf17ec0f-40aa-4106-b849-01704f56cf35-image.png
                bekomme jetzt die Fehlermeldung:
                11:02:36.426 error javascript.0 (10450) script.js.Ladeleistung: Cannot get quantity of undefined

                DJMarc75 paul53 2 Replies Last reply Reply Quote 0
                • DJMarc75
                  DJMarc75 @Kaspaani last edited by

                  @kaspaani Das ERSTE Element nehmen.

                  1 Reply Last reply Reply Quote 0
                  • paul53
                    paul53 @Kaspaani last edited by

                    @kaspaani
                    Die Liste hat nur ein Element (ein Objekt). Man muss also das 1. Element nehmen.

                    K 1 Reply Last reply Reply Quote 0
                    • K
                      Kaspaani @paul53 last edited by

                      @paul53 trotzdem die gleiche Meldung:
                      36586650-3abf-4808-8d86-61ab43b53380-image.png

                      bahnuhr liv-in-sky paul53 3 Replies Last reply Reply Quote 0
                      • bahnuhr
                        bahnuhr Forum Testing Most Active @Kaspaani last edited by

                        @kaspaani

                        Wie schon mehrfach berichtet; du musst das 1. Element nehmen.

                        Und dies ist [0]

                        @mickym sagte in Wert aus json:

                        @kaspaani Probier mal:

                        Wert[0].quantity
                        

                        als Attribut.

                        1 Reply Last reply Reply Quote 0
                        • liv-in-sky
                          liv-in-sky @Kaspaani last edited by

                          @kaspaani

                          wie erwähnt - das erste !

                          1672047858936-image-095.png

                          1 Reply Last reply Reply Quote 0
                          • paul53
                            paul53 @Kaspaani last edited by paul53

                            @kaspaani sagte: trotzdem die gleiche Meldung:

                            Dann checke es mal in einzelnen Schritten:

                            Bild_2022-12-26_111722173.png

                            EDIT: Log:

                            11:29:28.251	info	javascript.1 (2078) script.js.blockly.Test8_Blockly: [{'start':61,'end':100,'date':'24.12.2022 14:29','diff':154,'quantity':'25.74','price':'10.04','odo':3646,'basicPrice':0.39,'startDate':'24.12.2022 11:56','duration':154,'perHour':0.0027857142857142855}]
                            11:29:28.251	info	javascript.1 (2078) script.js.blockly.Test8_Blockly: {'start':61,'end':100,'date':'24.12.2022 14:29','diff':154,'quantity':'25.74','price':'10.04','odo':3646,'basicPrice':0.39,'startDate':'24.12.2022 11:56','duration':154,'perHour':0.0027857142857142855}
                            11:29:28.251	info	javascript.1 (2078) script.js.blockly.Test8_Blockly: 25.74
                            
                            K 1 Reply Last reply Reply Quote 0
                            • Homoran
                              Homoran Global Moderator Administrators @Kaspaani last edited by

                              @kaspaani sagte in Wert aus json:

                              Ich habe folgende JSON

                              bitte als Text in code-tags!

                              K 1 Reply Last reply Reply Quote 0
                              • K
                                Kaspaani @Homoran last edited by

                                @homoran meinst du das so?

                                [{"start":61,"end":100,"date":"24.12.2022 14:29","diff":154,"quantity":"25.74","price":"10.04","odo":3646,"basicPrice":0.39,"startDate":"24.12.2022 11:56","duration":154,"perHour":0.0027857142857142855}]
                                
                                Homoran 1 Reply Last reply Reply Quote 0
                                • paul53
                                  paul53 @Kaspaani last edited by

                                  @kaspaani sagte: Als Ansatz habe ich diesen:

                                  Du hast die asynchrone Version mit Callback-Funktion ausgewählt, die den Zustand des Datenpunktes in der Variablen state (nicht result) liefert.

                                  Bild_2022-12-26_112543838.png

                                  1 Reply Last reply Reply Quote 0
                                  • K
                                    Kaspaani @paul53 last edited by

                                    @paul53 Ich sehe den Wald vor lauter Bäumen nicht mehr. Ich finde das "setze ...auf" nicht.

                                    paul53 1 Reply Last reply Reply Quote 0
                                    • paul53
                                      paul53 @Kaspaani last edited by paul53

                                      @kaspaani sagte: Ich finde das "setze ...auf" nicht.

                                      Die Variable muss erst erstellt werden, damit "setze ... auf" angeboten wird.

                                      Bild_2022-12-26_114530977.png

                                      K 1 Reply Last reply Reply Quote 0
                                      • K
                                        Kaspaani @paul53 last edited by

                                        @paul53 Sieht jetzt so aus. Leider immer noch nicht das Ergebnis wie bei dir.
                                        256190d9-2b14-4566-bfea-17e4967c449d-image.png
                                        Mach ich was verkehrt mit der Obj ID?

                                        cc7f98df-35dd-4ad5-b545-5592edd7f3f6-image.png

                                        paul53 1 Reply Last reply Reply Quote 0
                                        • paul53
                                          paul53 @Kaspaani last edited by paul53

                                          @kaspaani sagte: Mach ich was verkehrt mit der Obj ID?

                                          Anscheinend ja: Der Datenpunkt "Charging history as json" enthält offenbar nicht das gezeigte JSON.
                                          Die 2 Log-Ausgaben oberhalb von "Cannot get ..." wären interessant gewesen.

                                          K 1 Reply Last reply Reply Quote 0
                                          • K
                                            Kaspaani @paul53 last edited by

                                            @paul53 Nach meinem Verständnis doch. Wenn man sich das hier ansieht.
                                            cd9d656e-ac07-4f26-96fc-dc0ba564b9df-image.png

                                            K 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            617
                                            Online

                                            32.0k
                                            Users

                                            80.5k
                                            Topics

                                            1.3m
                                            Posts

                                            7
                                            42
                                            818
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo