Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. [teilgelöst] Parser: bestimmtes Feld aus json

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [teilgelöst] Parser: bestimmtes Feld aus json

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

      Hallo zusammen,
      mal wieder eine Frage zum Thema Parser und ich bekomm den Regex einfach nicht hin.

      {
       "Feld1": "Info",
       "Feld2": "123",
       "Feld3": "456",
       "Feld4": [
        {
         "Feld1": "Info1",
         "Feld2": "789",
         "Feld3": "432"
        },
        {
         "Feld1": "Info2",
         "Feld2": "443",
         "Feld3": "677"
        },
        {
         "Feld1": "Info3",
         "Feld2": "432",
         "Feld3": "436"
        }
       ]
      }
      

      Nun hätte ich gern vom Info2 Block den Wert von Feld2.
      Kann mir da jemand einen Tipp geben?

      Vielen Dank
      5tift

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

        @5tift sagte: vom Info2 Block den Wert von Feld2.

        Weshalb Parser, wenn ein JSON vorliegt?

        Blockly_temp.JPG

        Javascript:

        JSON.parse(json).Feld4[1].Feld2
        
        5 1 Reply Last reply Reply Quote 0
        • 5
          5tift @paul53 last edited by

          @paul53
          Aktuell schreibt der Parser benötige Werte in die influxdb zur Visualisierung mittels Grafana.
          Wie würde das dann mit Blockly laufen?

          paul53 Homoran 2 Replies Last reply Reply Quote 0
          • paul53
            paul53 @5tift last edited by

            @5tift sagte: Wie würde das dann mit Blockly laufen?

            Anstelle von "debug output" per "aktualisiere" in einen eigenen Datenpunkt schreiben und diesen per influxDB historisieren.

            1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @5tift last edited by

              @5tift wenn es denn unbedingt der parser sein muss wäre der RegEx o1[^:]+[^\d]+(\d+)

              1 Reply Last reply Reply Quote 0
              • 5
                5tift last edited by 5tift

                @paul53 said in Parser: bestimmtes Feld aus json:
                Danke für den Input.
                Wie gebe ich in Blockly als Quelle vom json eine URL an?

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

                  @5tift sagte: in Blockly als Quelle vom json eine URL an?

                  Mit dem Block "request" (unter "Aktionen"). Das JSON wird dann in der Variablen result (erstellen!) zurück gegeben. Als Trigger muss ein Zeitplan dienen.

                  Blockly_temp.JPG

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

                    @paul53
                    Dank Dir für die Hilfe, ich werd mich morgen mal an die Umsetzung machen.

                    1 Reply Last reply Reply Quote 0
                    • 5
                      5tift last edited by 5tift

                      Das funktioniert echt gut 😊
                      Jetzt steht in einem Feld direkt hinter dem Wert noch eine Einheit.
                      Kann ich sagen nur Zahlen auswählen bzw. die Einheit abtrennen?

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

                        @5tift sagte: nur Zahlen auswählen bzw. die Einheit abtrennen?

                        Konvertieren "nach Zahl".

                        1 Reply Last reply Reply Quote 0
                        • 5
                          5tift last edited by

                          @paul53
                          und wo muss dieser Block rein?

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

                            @5tift sagte: wo muss dieser Block rein?

                            Vor "Attribut ...".

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

                              @paul53
                              Super, vielen Dank für Deine Hilfe.

                              1 Reply Last reply Reply Quote 0
                              • 5
                                5tift last edited by

                                Eine Frage hätte ich noch an die Experten hier.
                                Gibt es auch die Möglichkeit die unterschiedlichen Feld1 Positionen nach ihrem Inhalt zu selektieren.
                                Zum Beispiel wenn Feld1 mit .test+2 endet hätte ich die Ausgabe von Feld2 mit 443.

                                {
                                 "Feld1": "Info",
                                 "Feld2": "123",
                                 "Feld3": "456",
                                 "Feld4": [
                                  {
                                   "Feld1": "Info1.test+1",
                                   "Feld2": "789",
                                   "Feld3": "432"
                                  },
                                  {
                                   "Feld1": "Info1.test+2",
                                   "Feld2": "443",
                                   "Feld3": "677"
                                  },
                                  {
                                   "Feld1": "Info1.test+3",
                                   "Feld2": "432",
                                   "Feld3": "436"
                                  }
                                 ]
                                }
                                

                                Vielen Dank und entspannte Feiertage.

                                Homoran paul53 mickym 3 Replies Last reply Reply Quote 0
                                • Homoran
                                  Homoran Global Moderator Administrators @5tift last edited by

                                  @5tift sagte in [teilgelöst] Parser: bestimmtes Feld aus json:

                                  Zum Beispiel wenn Feld1 mit .test+2 endet hätte ich die Ausgabe von Feld2 mit 443.

                                  welches?

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

                                    @5tift sagte: Gibt es auch die Möglichkeit die unterschiedlichen Feld1 Positionen nach ihrem Inhalt zu selektieren.

                                    Ja, in einer Schleife. Kommen denn die Felder nicht immer in gleicher Reihenfolge in der Liste von "Feld4"?

                                    5 1 Reply Last reply Reply Quote 0
                                    • 5
                                      5tift @Homoran last edited by

                                      @homoran
                                      es sind die Positionen unter Feld4

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

                                        @paul53
                                        Die Werte / Felder können unter Umständen nach Inaktivität wieder am Ende angereiht werden, somit ist nur der Wert .xyz von Feld1 eindeutig.

                                        Homoran paul53 2 Replies Last reply Reply Quote 0
                                        • Homoran
                                          Homoran Global Moderator Administrators @5tift last edited by

                                          @5tift ich verstehe es nicht.

                                          es gibt mehrere Elemente mit Feld1.xyz unter Feld 4

                                          um welches geht's denn

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

                                            @5tift sagte: nur der Wert .xyz von Feld1 eindeutig.

                                            Die Schleife:

                                            Blockly_temp.JPG

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            631
                                            Online

                                            31.7k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            4
                                            33
                                            970
                                            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