Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Objekt in JSON Array umwandeln

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Objekt in JSON Array umwandeln

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

      Folgenden Objekt erhalte ich per API Abruf...

      {'time':['2022-03-01','2022-03-02','2022-03-03','2022-03-04','2022-03-05','2022-03-06','2022-03-07','2022-03-08'],'pictocode':[2,2,2,2,1,2,2,2],'uvindex':[3,2,2,3,3,2,2,2],'temperature_max':[9.55,11.29,13.07,10.56,9.06,8.07,9.19,8.98],'temperature_min':[-0.3,-0.47,2.34,0.42,-1.79,-1.73,-1.18,-1.43],'temperature_mean':[4.34,5.12,7.27,5,3.12,2.92,3.53,3.53],'felttemperature_max':[5.63,8.28,9.82,6.61,3.86,3.58,4.82,2.45],'felttemperature_min':[-4.93,-4.59,-0.68,-2.47,-5.69,-5.55,-5.04,-5.47],'winddirection':[135,135,0,180,90,90,45,90],'precipitation_probability':[0,0,1,1,0,5,3,4],'rainspot':['0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000'],'predictability_class':[5,4,4,4,4,4,3,3],'predictability':[82,78,77,72,74,69,60,50],'precipitation':[0,0,0,0,0,0,0,0],'snowfraction':[0,0,0,0,0,0,0,0],'sealevelpressure_max':[1029,1027,1020,1020,1021,1023,1022,1018],'sealevelpressure_min':[1026,1020,1014,1017,1019,1020,1017,1010],'sealevelpressure_mean':[1028,1023,1017,1018,1020,1021,1020,1013],'windspeed_max':[2.7,2.1,2.31,2.32,2.88,2.08,2.25,5.2],'windspeed_mean':[1.68,1.22,1.29,1.36,1.93,1.36,1.52,3.64],'windspeed_min':[0.64,0.49,0.49,0.45,0.94,0.57,0.55,1.73],'relativehumidity_max':[63,73,81,82,65,54,63,78],'relativehumidity_min':[26,40,42,37,25,27,33,31],'relativehumidity_mean':[45,56,63,60,41,40,45,53],'convective_precipitation':[0,0,0,0,0,0,0,0],'precipitation_hours':[0,0,0,0,0,0,0,0],'humiditygreater90_hours':[0,0,0,0,0,0,0,0],'indexto1hvalues_start':[0,24,48,72,96,120,144,168],'indexto1hvalues_end':[23,47,71,95,119,143,167,191]}
      

      Ich würde jetzt gerne diese Daten in dem MaterialDesign-Widget Table verwenden. Dazu muss das Objekt ja noch in ein JSON Array umgewandelt werden.
      Leider sind meine Javascript Fähigkeiten noch nicht so weit, und ich schaffe es nicht dieses Objekt umzuwandeln.
      Könnt Ihr mir auf die Sprünge helfen?

      Könnte ich auch nur Teile dieses Objektes verwenden?

      Danke für Eure Hilfe 😊

      Dirk

      OliverIO Sokomoto paul53 4 Replies Last reply Reply Quote 0
      • OliverIO
        OliverIO @dirk_1930 last edited by

        @dirk_1930

        also als erstes beschreibt dieses JSON ein objekt mit vielen Attributen.
        Die Attribute sind wiederum immer Arrays.

        Um den Text in ein verarbeitbares Objekt umzuwandeln wendest du den folgenden Befehl an:

        var obj = JSON.parse(variableDieDenJSONTextEnthält);
        

        um danach noch beispielsweise nur das windspeed_max array weiterzu verwenden

        var windMax = obj.windspeed_max
        

        um auf das erste Element des Arrays zugreifen zu können

        console.debug(windMax[0]);
        

        Leider weiß ich nicht in welcher Form das table widget die Daten erwartet.
        Aber evtl hilft dir das weiter

        dirk_1930 1 Reply Last reply Reply Quote 0
        • dirk_1930
          dirk_1930 @OliverIO last edited by

          @oliverio
          Danke für die schnelle Antwort...

          Laut Beschreibung soll das JSON folgende Struktur haben:
          Data - JSON Stucture
          Input data must be a json array of objects. You can use any property, there is no fixes structure. Column 0 gets the value of the first property, column 1 gets the value of the second property and so on. Important is, that every Object has the same structure.

          [
          	{
          		"img": "/vis.0/myImages/erlebnis_50.png",
          		"name": "Empire",
          		"betriebszeit": "4h 06m",
          		"funk": "5G",
          		"ip": "10.0.0.1"
          	},
          	{
          		"img": "/vis.0/myImages/erlebnis_100.png",
          		"name": "Handy",
          		"betriebszeit": "13m",
          		"funk": "5G",
          		"ip": "10.0.0.2"
          	},
          	{
          		"img": "/vis.0/myImages/erlebnis_100.png",
          		"name": "Harmony Hub - Wohnzimmer",
          		"betriebszeit": "18T 07h 21m",
          		"funk": "2G",
          		"ip": "10.0.0.3"
          	}
          ]
          
          liv-in-sky OliverIO 2 Replies Last reply Reply Quote 0
          • Sokomoto
            Sokomoto @dirk_1930 last edited by

            @dirk_1930 sagte in Objekt in JSON Array umwandeln:

            Folgenden Objekt erhalte ich per API Abruf...

            Dein String verwendet einfache Anführungszeichen anstelle von doppelten Anführungszeichen.
            Das Problem sind die Anführungszeichen, wandle die mal in " um, mit Notepad++ z.B, dann passt das.

            x=deinString
            var obj=JSON.parse(x);
            log( 'Ausgabe = '+obj.time[0])
            console>Ausgabe = 2022-03-01

            tschuess

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

              @sokomoto sagte: Dein String verwendet einfache Anführungszeichen anstelle von doppelten Anführungszeichen.

              Das ist kein String (JSON), sondern ein Objekt. Umwandlung in JSON:

              let json = JSON.stringify(obj);
              
              1 Reply Last reply Reply Quote 0
              • liv-in-sky
                liv-in-sky @dirk_1930 last edited by liv-in-sky

                @dirk_1930

                kann dir nur eine umwandlung in ein anderes json bieten

                die anpassung an material design ist nicht dabei - da brauchst du wieder ein script, welches die umsetzung macht - mit dem erbnis von hier

                du kannst das im inventwo json widget ansehen

                du musst dir einen datenpunkt anlegen und im blockly auswählen

                Image 5.png

                <xml xmlns="https://developers.google.com/blockly/xml">
                 <variables>
                   <variable id="ufb_74:Rl4u[t3tsm-)U">x</variable>
                   <variable id="?j:hG`+CH@lHRS#sl=BF">myString</variable>
                   <variable id="ju_axXKM0evm)kFjt0^x">i</variable>
                   <variable id="Z=?7wCQ1-49/,bxoE1#|">counter</variable>
                 </variables>
                 <block type="procedures_defcustomreturn" id="*YUTilQ+*5,A$vpoL$Ot" x="588" y="-487">
                   <mutation statements="false">
                     <arg name="x" varid="ufb_74:Rl4u[t3tsm-)U"></arg>
                   </mutation>
                   <field name="NAME">etwas tun</field>
                   <field name="SCRIPT">cmV0dXJuIHgucmVwbGFjZSgvJy9tZywnIicpOw==</field>
                   <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                 </block>
                 <block type="variables_set" id=",,sDrj|CT[_JGj8(=lh[" x="138" y="-412">
                   <field name="VAR" id="?j:hG`+CH@lHRS#sl=BF">myString</field>
                   <value name="VALUE">
                     <block type="procedures_callcustomreturn" id="v,5a7cp]qV9^543W(:A9">
                       <mutation name="etwas tun">
                         <arg name="x"></arg>
                       </mutation>
                       <value name="ARG0">
                         <block type="text" id="{+_|6aTnAzc)dJxtBbO,">
                           <field name="TEXT">{'time':['2022-03-01','2022-03-02','2022-03-03','2022-03-04','2022-03-05','2022-03-06','2022-03-07','2022-03-08'],'pictocode':[2,2,2,2,1,2,2,2],'uvindex':[3,2,2,3,3,2,2,2],'temperature_max':[9.55,11.29,13.07,10.56,9.06,8.07,9.19,8.98],'temperature_min':[-0.3,-0.47,2.34,0.42,-1.79,-1.73,-1.18,-1.43],'temperature_mean':[4.34,5.12,7.27,5,3.12,2.92,3.53,3.53],'felttemperature_max':[5.63,8.28,9.82,6.61,3.86,3.58,4.82,2.45],'felttemperature_min':[-4.93,-4.59,-0.68,-2.47,-5.69,-5.55,-5.04,-5.47],'winddirection':[135,135,0,180,90,90,45,90],'precipitation_probability':[0,0,1,1,0,5,3,4],'rainspot':['0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000','0000000000000000000000000000000000000000000000000'],'predictability_class':[5,4,4,4,4,4,3,3],'predictability':[82,78,77,72,74,69,60,50],'precipitation':[0,0,0,0,0,0,0,0],'snowfraction':[0,0,0,0,0,0,0,0],'sealevelpressure_max':[1029,1027,1020,1020,1021,1023,1022,1018],'sealevelpressure_min':[1026,1020,1014,1017,1019,1020,1017,1010],'sealevelpressure_mean':[1028,1023,1017,1018,1020,1021,1020,1013],'windspeed_max':[2.7,2.1,2.31,2.32,2.88,2.08,2.25,5.2],'windspeed_mean':[1.68,1.22,1.29,1.36,1.93,1.36,1.52,3.64],'windspeed_min':[0.64,0.49,0.49,0.45,0.94,0.57,0.55,1.73],'relativehumidity_max':[63,73,81,82,65,54,63,78],'relativehumidity_min':[26,40,42,37,25,27,33,31],'relativehumidity_mean':[45,56,63,60,41,40,45,53],'convective_precipitation':[0,0,0,0,0,0,0,0],'precipitation_hours':[0,0,0,0,0,0,0,0],'humiditygreater90_hours':[0,0,0,0,0,0,0,0],'indexto1hvalues_start':[0,24,48,72,96,120,144,168],'indexto1hvalues_end':[23,47,71,95,119,143,167,191]} </field>
                         </block>
                       </value>
                     </block>
                   </value>
                   <next>
                     <block type="debug" id="|n`0($^$DSDq@#M|v`*N" disabled="true">
                       <field name="Severity">log</field>
                       <value name="TEXT">
                         <shadow type="text" id="c:Qeo]i#$^2~!(3:4s0{">
                           <field name="TEXT">test</field>
                         </shadow>
                         <block type="convert_tostring" id="-X|5=a7cpnmLlErO9Hvx">
                           <value name="VALUE">
                             <block type="get_attr" id="0~^wix__Ktr9/LT7|!Lc">
                               <value name="PATH">
                                 <shadow type="text" id="77PNfY!@sD64E3l^[R=s">
                                   <field name="TEXT">time</field>
                                 </shadow>
                               </value>
                               <value name="OBJECT">
                                 <block type="variables_get" id="?h#Qe+(fX2K3h2DKJr4Z">
                                   <field name="VAR" id="?j:hG`+CH@lHRS#sl=BF">myString</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="debug" id="c*?oUN6,O[a4XIQ|p(27">
                           <field name="Severity">log</field>
                           <value name="TEXT">
                             <shadow type="text" id="krDt]i3.}2gSZh)hD]u%">
                               <field name="TEXT">test</field>
                             </shadow>
                             <block type="procedures_callcustomreturn" id="x6ncpwY9,Mk!Q3{nQ2|J">
                               <mutation name="etwas tun2">
                                 <arg name="x"></arg>
                               </mutation>
                               <value name="ARG0">
                                 <block type="variables_get" id="HYhKCKl-s~SHhwm^$GGb">
                                   <field name="VAR" id="?j:hG`+CH@lHRS#sl=BF">myString</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                           <next>
                             <block type="control" id="T!5@xzFe0un^1}L9j7Mq">
                               <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                               <field name="OID">0_userdata.0.CONTROL-OWN.AAATEST.TestString6</field>
                               <field name="WITH_DELAY">FALSE</field>
                               <value name="VALUE">
                                 <block type="procedures_callcustomreturn" id="dd/xz=!@9[?c$}$gI.Rs">
                                   <mutation name="etwas tun2">
                                     <arg name="x"></arg>
                                   </mutation>
                                   <value name="ARG0">
                                     <block type="variables_get" id=".(mq%vXfphFT:A6i,j0*">
                                       <field name="VAR" id="?j:hG`+CH@lHRS#sl=BF">myString</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
                 <block type="procedures_defcustomreturn" id="cfAe~MsgrVq?.?[9mYb@" x="638" y="-438">
                   <mutation statements="false">
                     <arg name="x" varid="ufb_74:Rl4u[t3tsm-)U"></arg>
                   </mutation>
                   <field name="NAME">etwas tun2</field>
                   <field name="SCRIPT">DQoNCmxldCBteU5ld0Fycj1bXQ0KeXk9SlNPTi5wYXJzZSh4KQ0KLy9sb2coeS50aW1lKQ0KDQogdmFyIGtleXNGaXJzdCA9IE9iamVjdC5rZXlzKHl5KTsNCg0KbGV0IGNvdW50ZXI9MA0KbGV0IG15TGVuZ3RoPSh5eVtrZXlzRmlyc3RbMF1dKS5sZW5ndGgNCiBsZXQgbmV3SXNzdWUNCiBsZXQgbmV3SnNvbj17fQ0KDQogIGZvcihsZXQgdT0wO3U8bXlMZW5ndGg7dSsrKXsNCiAgICAgDQogICAgICBuZXdJc3N1ZT1bXQ0KICAgIGZvcihsZXQgdXU9MDsgdXU8a2V5c0ZpcnN0Lmxlbmd0aDt1dSsrKXsNCiAgICAgIGxldCB6ej15eVtrZXlzRmlyc3RbdXVdXQ0KIA0KICAgICAgbmV3SXNzdWUucHVzaCh7DQogICAgICAgICAgIFtrZXlzRmlyc3RbdXVdXSA6ICh5eVtrZXlzRmlyc3RbdXVdXSlbdV0NCiAgICAgIH0NCiAgICAgICAgICApDQogICAgfSAgIA0KIA0KICBsb2cobmV3SXNzdWUubGVuZ3RoKQ0KIGZvcihsZXQgYT0wO2E8bmV3SXNzdWUubGVuZ3RoO2ErKyl7DQogICBsb2cobmV3SXNzdWVbYV0pDQogIG5ld0pzb249IHsuLi5uZXdKc29uLCAuLi5uZXdJc3N1ZVthXSB9DQogIA0KIH0NCiBteU5ld0Fyci5wdXNoKG5ld0pzb24pDQogICB9DQoNCiAgDQoNCnJldHVybiBteU5ld0FycjsNCg0K</field>
                   <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
                 </block>
                 <block type="controls_forEach" id="jL-wx^K=wd/$._Lu`8MU" disabled="true" x="-313" y="-87">
                   <field name="VAR" id="ju_axXKM0evm)kFjt0^x">i</field>
                   <statement name="DO">
                     <block type="math_change" id="/(`nr]L}0~UAa;X|Nm3V">
                       <field name="VAR" id="Z=?7wCQ1-49/,bxoE1#|">counter</field>
                       <value name="DELTA">
                         <shadow xmlns="http://www.w3.org/1999/xhtml" type="math_number" id="sN*$vrmlN4}$m!x%0/}W">
                           <field name="NUM">1</field>
                         </shadow>
                         <block type="math_number" id=";=rNkeJrp_)K.+TproOf">
                           <field name="NUM">1</field>
                         </block>
                       </value>
                       <next>
                         <block type="debug" id="u{V[RjJVxAB+H/VInKER">
                           <field name="Severity">log</field>
                           <value name="TEXT">
                             <shadow type="text" id="$0=*eBZ5gCWFxE6sr,9)">
                               <field name="TEXT">test</field>
                             </shadow>
                             <block type="variables_get" id="YR@ccm#6%FohNIpMfRDe">
                               <field name="VAR" id="ju_axXKM0evm)kFjt0^x">i</field>
                             </block>
                           </value>
                         </block>
                       </next>
                     </block>
                   </statement>
                 </block>
                </xml>
                

                die inventwo widgets müssen installiert sein, bei den adaptern

                [{"tpl":"i-vis-jsontable","data":{"g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","iTblRowLimit":"41","iTableRefreshRate":"0","iTblSortOrder":"asc","iColCount":"28","iColShow1":"true","iTblHeadTextAlign1":"center","iTblTextAlign1":"left","iTblCellFormat1":"normal","iTblCellImageSize1":"200","iTblCellBooleanCheckbox1":"false","iTblCellBooleanColorFalse1":"#ff0000","iTblCellBooleanColorTrue1":"#00ff00","iTblCellNumberDecimals1":"2","iTblCellNumberDecimalSeperator1":".","iTblCellNumberThousandSeperator1":",","iTblCellThresholdsDp1":"","iTblCellThresholdsText1":"","iOpacityAll":"1","iTblRowEvenColor":"#333333","iTblRowUnevenColor":"#455618","iTblHeaderColor":"#333333","iRowSpacing":"10","iTblRowEvenTextColor":"#ffffff","iTblRowUnevenTextColor":"#ffffff","iTblHeaderTextColor":"#ffffff","iBorderSize":"0","iBorderStyleLeft":"none","iBorderStyleRight":"none","iBorderStyleUp":"none","iBorderStyleDown":"none","iBorderColor":"#ffffff","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"oid":"0_userdata.0.CONTROL-OWN.AAATEST.TestString6","iColShow2":"true","iTblHeadTextAlign2":"center","iTblTextAlign2":"left","iTblCellFormat2":"normal","iTblCellImageSize2":"200","iTblCellBooleanCheckbox2":"false","iTblCellBooleanColorFalse2":"#ff0000","iTblCellBooleanColorTrue2":"#00ff00","iTblCellNumberDecimals2":"2","iTblCellNumberDecimalSeperator2":".","iTblCellNumberThousandSeperator2":",","iTblCellThresholdsDp2":"","iTblCellThresholdsText2":"","iColShow3":"true","iTblHeadTextAlign3":"center","iTblTextAlign3":"left","iTblCellFormat3":"normal","iTblCellImageSize3":"200","iTblCellBooleanCheckbox3":"false","iTblCellBooleanColorFalse3":"#ff0000","iTblCellBooleanColorTrue3":"#00ff00","iTblCellNumberDecimals3":"2","iTblCellNumberDecimalSeperator3":".","iTblCellNumberThousandSeperator3":",","iTblCellThresholdsDp3":"","iTblCellThresholdsText3":"","iColShow4":"true","iTblHeadTextAlign4":"center","iTblTextAlign4":"left","iTblCellFormat4":"normal","iTblCellImageSize4":"200","iTblCellBooleanCheckbox4":"false","iTblCellBooleanColorFalse4":"#ff0000","iTblCellBooleanColorTrue4":"#00ff00","iTblCellNumberDecimals4":"2","iTblCellNumberDecimalSeperator4":".","iTblCellNumberThousandSeperator4":",","iTblCellThresholdsDp4":"","iTblCellThresholdsText4":"","iColShow5":"true","iTblHeadTextAlign5":"center","iTblTextAlign5":"left","iTblCellFormat5":"normal","iTblCellImageSize5":"200","iTblCellBooleanCheckbox5":"false","iTblCellBooleanColorFalse5":"#ff0000","iTblCellBooleanColorTrue5":"#00ff00","iTblCellNumberDecimals5":"2","iTblCellNumberDecimalSeperator5":".","iTblCellNumberThousandSeperator5":",","iTblCellThresholdsDp5":"","iTblCellThresholdsText5":"","iColShow6":"true","iTblHeadTextAlign6":"center","iTblTextAlign6":"left","iTblCellFormat6":"normal","iTblCellImageSize6":"200","iTblCellBooleanCheckbox6":"false","iTblCellBooleanColorFalse6":"#ff0000","iTblCellBooleanColorTrue6":"#00ff00","iTblCellNumberDecimals6":"2","iTblCellNumberDecimalSeperator6":".","iTblCellNumberThousandSeperator6":",","iTblCellThresholdsDp6":"","iTblCellThresholdsText6":"","iColShow7":"true","iTblHeadTextAlign7":"center","iTblTextAlign7":"left","iTblCellFormat7":"normal","iTblCellImageSize7":"200","iTblCellBooleanCheckbox7":"false","iTblCellBooleanColorFalse7":"#ff0000","iTblCellBooleanColorTrue7":"#00ff00","iTblCellNumberDecimals7":"2","iTblCellNumberDecimalSeperator7":".","iTblCellNumberThousandSeperator7":",","iTblCellThresholdsDp7":"","iTblCellThresholdsText7":"","iColShow8":"true","iTblHeadTextAlign8":"center","iTblTextAlign8":"left","iTblCellFormat8":"normal","iTblCellImageSize8":"200","iTblCellBooleanCheckbox8":"false","iTblCellBooleanColorFalse8":"#ff0000","iTblCellBooleanColorTrue8":"#00ff00","iTblCellNumberDecimals8":"2","iTblCellNumberDecimalSeperator8":".","iTblCellNumberThousandSeperator8":",","iTblCellThresholdsDp8":"","iTblCellThresholdsText8":"","iColShow9":"true","iTblHeadTextAlign9":"center","iTblTextAlign9":"left","iTblCellFormat9":"normal","iTblCellImageSize9":"200","iTblCellBooleanCheckbox9":"false","iTblCellBooleanColorFalse9":"#ff0000","iTblCellBooleanColorTrue9":"#00ff00","iTblCellNumberDecimals9":"2","iTblCellNumberDecimalSeperator9":".","iTblCellNumberThousandSeperator9":",","iTblCellThresholdsDp9":"","iTblCellThresholdsText9":"","iColShow10":"true","iTblHeadTextAlign10":"center","iTblTextAlign10":"left","iTblCellFormat10":"normal","iTblCellImageSize10":"200","iTblCellBooleanCheckbox10":"false","iTblCellBooleanColorFalse10":"#ff0000","iTblCellBooleanColorTrue10":"#00ff00","iTblCellNumberDecimals10":"2","iTblCellNumberDecimalSeperator10":".","iTblCellNumberThousandSeperator10":",","iTblCellThresholdsDp10":"","iTblCellThresholdsText10":"","iColShow11":false,"iTblHeadTextAlign11":"center","iTblTextAlign11":"left","iTblCellFormat11":"normal","iTblCellImageSize11":"200","iTblCellBooleanCheckbox11":"false","iTblCellBooleanColorFalse11":"#ff0000","iTblCellBooleanColorTrue11":"#00ff00","iTblCellNumberDecimals11":"2","iTblCellNumberDecimalSeperator11":".","iTblCellNumberThousandSeperator11":",","iTblCellThresholdsDp11":"","iTblCellThresholdsText11":"","iColShow12":"true","iTblHeadTextAlign12":"center","iTblTextAlign12":"left","iTblCellFormat12":"normal","iTblCellImageSize12":"200","iTblCellBooleanCheckbox12":"false","iTblCellBooleanColorFalse12":"#ff0000","iTblCellBooleanColorTrue12":"#00ff00","iTblCellNumberDecimals12":"2","iTblCellNumberDecimalSeperator12":".","iTblCellNumberThousandSeperator12":",","iTblCellThresholdsDp12":"","iTblCellThresholdsText12":"","iColShow13":"true","iTblHeadTextAlign13":"center","iTblTextAlign13":"left","iTblCellFormat13":"normal","iTblCellImageSize13":"200","iTblCellBooleanCheckbox13":"false","iTblCellBooleanColorFalse13":"#ff0000","iTblCellBooleanColorTrue13":"#00ff00","iTblCellNumberDecimals13":"2","iTblCellNumberDecimalSeperator13":".","iTblCellNumberThousandSeperator13":",","iTblCellThresholdsDp13":"","iTblCellThresholdsText13":"","iColShow14":"true","iTblHeadTextAlign14":"center","iTblTextAlign14":"left","iTblCellFormat14":"normal","iTblCellImageSize14":"200","iTblCellBooleanCheckbox14":"false","iTblCellBooleanColorFalse14":"#ff0000","iTblCellBooleanColorTrue14":"#00ff00","iTblCellNumberDecimals14":"2","iTblCellNumberDecimalSeperator14":".","iTblCellNumberThousandSeperator14":",","iTblCellThresholdsDp14":"","iTblCellThresholdsText14":"","iColShow15":"true","iTblHeadTextAlign15":"center","iTblTextAlign15":"left","iTblCellFormat15":"normal","iTblCellImageSize15":"200","iTblCellBooleanCheckbox15":"false","iTblCellBooleanColorFalse15":"#ff0000","iTblCellBooleanColorTrue15":"#00ff00","iTblCellNumberDecimals15":"2","iTblCellNumberDecimalSeperator15":".","iTblCellNumberThousandSeperator15":",","iTblCellThresholdsDp15":"","iTblCellThresholdsText15":"","iColShow16":"true","iTblHeadTextAlign16":"center","iTblTextAlign16":"left","iTblCellFormat16":"normal","iTblCellImageSize16":"200","iTblCellBooleanCheckbox16":"false","iTblCellBooleanColorFalse16":"#ff0000","iTblCellBooleanColorTrue16":"#00ff00","iTblCellNumberDecimals16":"2","iTblCellNumberDecimalSeperator16":".","iTblCellNumberThousandSeperator16":",","iTblCellThresholdsDp16":"","iTblCellThresholdsText16":"","iColShow17":"true","iTblHeadTextAlign17":"center","iTblTextAlign17":"left","iTblCellFormat17":"normal","iTblCellImageSize17":"200","iTblCellBooleanCheckbox17":"false","iTblCellBooleanColorFalse17":"#ff0000","iTblCellBooleanColorTrue17":"#00ff00","iTblCellNumberDecimals17":"2","iTblCellNumberDecimalSeperator17":".","iTblCellNumberThousandSeperator17":",","iTblCellThresholdsDp17":"","iTblCellThresholdsText17":"","iColShow18":"true","iTblHeadTextAlign18":"center","iTblTextAlign18":"left","iTblCellFormat18":"normal","iTblCellImageSize18":"200","iTblCellBooleanCheckbox18":"false","iTblCellBooleanColorFalse18":"#ff0000","iTblCellBooleanColorTrue18":"#00ff00","iTblCellNumberDecimals18":"2","iTblCellNumberDecimalSeperator18":".","iTblCellNumberThousandSeperator18":",","iTblCellThresholdsDp18":"","iTblCellThresholdsText18":"","iColShow19":"true","iTblHeadTextAlign19":"center","iTblTextAlign19":"left","iTblCellFormat19":"normal","iTblCellImageSize19":"200","iTblCellBooleanCheckbox19":"false","iTblCellBooleanColorFalse19":"#ff0000","iTblCellBooleanColorTrue19":"#00ff00","iTblCellNumberDecimals19":"2","iTblCellNumberDecimalSeperator19":".","iTblCellNumberThousandSeperator19":",","iTblCellThresholdsDp19":"","iTblCellThresholdsText19":"","iColShow20":"true","iTblHeadTextAlign20":"center","iTblTextAlign20":"left","iTblCellFormat20":"normal","iTblCellImageSize20":"200","iTblCellBooleanCheckbox20":"false","iTblCellBooleanColorFalse20":"#ff0000","iTblCellBooleanColorTrue20":"#00ff00","iTblCellNumberDecimals20":"2","iTblCellNumberDecimalSeperator20":".","iTblCellNumberThousandSeperator20":",","iTblCellThresholdsDp20":"","iTblCellThresholdsText20":"","iColShow21":"true","iTblHeadTextAlign21":"center","iTblTextAlign21":"left","iTblCellFormat21":"normal","iTblCellImageSize21":"200","iTblCellBooleanCheckbox21":"false","iTblCellBooleanColorFalse21":"#ff0000","iTblCellBooleanColorTrue21":"#00ff00","iTblCellNumberDecimals21":"2","iTblCellNumberDecimalSeperator21":".","iTblCellNumberThousandSeperator21":",","iTblCellThresholdsDp21":"","iTblCellThresholdsText21":"","iColShow22":"true","iTblHeadTextAlign22":"center","iTblTextAlign22":"left","iTblCellFormat22":"normal","iTblCellImageSize22":"200","iTblCellBooleanCheckbox22":"false","iTblCellBooleanColorFalse22":"#ff0000","iTblCellBooleanColorTrue22":"#00ff00","iTblCellNumberDecimals22":"2","iTblCellNumberDecimalSeperator22":".","iTblCellNumberThousandSeperator22":",","iTblCellThresholdsDp22":"","iTblCellThresholdsText22":"","iColShow23":"true","iTblHeadTextAlign23":"center","iTblTextAlign23":"left","iTblCellFormat23":"normal","iTblCellImageSize23":"200","iTblCellBooleanCheckbox23":"false","iTblCellBooleanColorFalse23":"#ff0000","iTblCellBooleanColorTrue23":"#00ff00","iTblCellNumberDecimals23":"2","iTblCellNumberDecimalSeperator23":".","iTblCellNumberThousandSeperator23":",","iTblCellThresholdsDp23":"","iTblCellThresholdsText23":"","iColShow24":"true","iTblHeadTextAlign24":"center","iTblTextAlign24":"left","iTblCellFormat24":"normal","iTblCellImageSize24":"200","iTblCellBooleanCheckbox24":"false","iTblCellBooleanColorFalse24":"#ff0000","iTblCellBooleanColorTrue24":"#00ff00","iTblCellNumberDecimals24":"2","iTblCellNumberDecimalSeperator24":".","iTblCellNumberThousandSeperator24":",","iTblCellThresholdsDp24":"","iTblCellThresholdsText24":"","iColShow25":"true","iTblHeadTextAlign25":"center","iTblTextAlign25":"left","iTblCellFormat25":"normal","iTblCellImageSize25":"200","iTblCellBooleanCheckbox25":"false","iTblCellBooleanColorFalse25":"#ff0000","iTblCellBooleanColorTrue25":"#00ff00","iTblCellNumberDecimals25":"2","iTblCellNumberDecimalSeperator25":".","iTblCellNumberThousandSeperator25":",","iTblCellThresholdsDp25":"","iTblCellThresholdsText25":"","iColShow26":"true","iTblHeadTextAlign26":"center","iTblTextAlign26":"left","iTblCellFormat26":"normal","iTblCellImageSize26":"200","iTblCellBooleanCheckbox26":"false","iTblCellBooleanColorFalse26":"#ff0000","iTblCellBooleanColorTrue26":"#00ff00","iTblCellNumberDecimals26":"2","iTblCellNumberDecimalSeperator26":".","iTblCellNumberThousandSeperator26":",","iTblCellThresholdsDp26":"","iTblCellThresholdsText26":"","iColShow27":"true","iTblHeadTextAlign27":"center","iTblTextAlign27":"left","iTblCellFormat27":"normal","iTblCellImageSize27":"200","iTblCellBooleanCheckbox27":"false","iTblCellBooleanColorFalse27":"#ff0000","iTblCellBooleanColorTrue27":"#00ff00","iTblCellNumberDecimals27":"2","iTblCellNumberDecimalSeperator27":".","iTblCellNumberThousandSeperator27":",","iTblCellThresholdsDp27":"","iTblCellThresholdsText27":"","iColShow28":"true","iTblHeadTextAlign28":"center","iTblTextAlign28":"left","iTblCellFormat28":"normal","iTblCellImageSize28":"200","iTblCellBooleanCheckbox28":"false","iTblCellBooleanColorFalse28":"#ff0000","iTblCellBooleanColorTrue28":"#00ff00","iTblCellNumberDecimals28":"2","iTblCellNumberDecimalSeperator28":".","iTblCellNumberThousandSeperator28":",","iTblCellThresholdsDp28":"","iTblCellThresholdsText28":"","iTblShowHead":false},"style":{"left":"37px","top":"135px","width":"1344px","height":"562px"},"widgetSet":"vis-inventwo"}]
                

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

                  @dirk_1930 sagte: MaterialDesign-Widget Table

                  Das Original-Objekt mit vielen Arrays muss erst in ein Array mit vielen Objekten gewandelt und anschließend nach JSON konvertiert werden.

                  const arr = [];
                  const time = obj.time; // 1. Array im Original-Objekt
                  
                  for(let i = 0; i < time.length; i++) {
                      const newObj = {};
                      for(let prop in obj) {
                          newObj[prop] = obj[prop][i];
                      }
                      arr.push(newObj);
                  }
                  setState(idJson, JSON.stringify(arr), true)
                  
                  1 Reply Last reply Reply Quote 0
                  • OliverIO
                    OliverIO @dirk_1930 last edited by OliverIO

                    @dirk_1930 sagte in Objekt in JSON Array umwandeln:

                    @oliverio
                    Danke für die schnelle Antwort...

                    Laut Beschreibung soll das JSON folgende Struktur haben:
                    Data - JSON Stucture
                    Input data must be a json array of objects. You can use any property, there is no fixes structure. Column 0 gets the value of the first property, column 1 gets the value of the second property and so on. Important is, that every Object has the same structure.

                    [
                    	{
                    		"img": "/vis.0/myImages/erlebnis_50.png",
                    		"name": "Empire",
                    		"betriebszeit": "4h 06m",
                    		"funk": "5G",
                    		"ip": "10.0.0.1"
                    	},
                    	{
                    		"img": "/vis.0/myImages/erlebnis_100.png",
                    		"name": "Handy",
                    		"betriebszeit": "13m",
                    		"funk": "5G",
                    		"ip": "10.0.0.2"
                    	},
                    	{
                    		"img": "/vis.0/myImages/erlebnis_100.png",
                    		"name": "Harmony Hub - Wohnzimmer",
                    		"betriebszeit": "18T 07h 21m",
                    		"funk": "2G",
                    		"ip": "10.0.0.3"
                    	}
                    ]
                    

                    Das muss nicht exakt diese Struktur sein, denke ich. aber da musst du in der Doku nachlesen.
                    Aber ich denke es müsste wie folgt sein, Ein Array von Objekten, ein Objekt ist eine Zeile, jedes Attribut ist eine Spalte, also:

                    [
                    {
                    "name" : "zeile1",
                    "feld1":"feld1",
                    "feld2":"feld2"
                    },
                    {
                    "name" : "zeile2",
                    "feld1":"feld1",
                    "feld2":"feld2"
                    },
                    {
                    "name" : "zeile3",
                    "feld1":"feld1",
                    "feld2":"feld2"
                    }
                    ]
                    

                    müsste eine tabelle mit 3 zeilen und 3 spalten ergeben

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

                      @dirk_1930 sagte: Könnte ich auch nur Teile dieses Objektes verwenden?

                      Verwende eine Liste mit den zu selektierenden Eigenschaften:

                      const idJson = '0_userdata.0.xyz'; // Ziel-DP mit JSON-Tabelle
                      const selector = ['time', 'uvindex', 'temperature_mean'];
                      
                      // Objekt in Variable obj einlesen
                      const arr = [];
                      const length = obj.time.length; // Länge 1. Array im Original-Objekt
                      for(let i = 0; i < length; i++) {
                          const newObj = {};
                          for(let prop in obj) {
                              if(selector.includes(prop)) newObj[prop] = obj[prop][i];
                          }
                          arr.push(newObj);
                      }
                      setState(idJson, JSON.stringify(arr), true);
                      
                      dirk_1930 1 Reply Last reply Reply Quote 0
                      • dirk_1930
                        dirk_1930 @paul53 last edited by

                        @paul53
                        👍 😳 Perfekt... Vielen Dank für die Hilfe!

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        393
                        Online

                        31.8k
                        Users

                        80.0k
                        Topics

                        1.3m
                        Posts

                        5
                        10
                        208
                        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