Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. JSON parsen

    NEWS

    • 15. 05. Wartungsarbeiten am ioBroker Forum

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    JSON parsen

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

      Für den FlexCharts-Adapter von @jrbwh möchte ich ein als JSON gespeichertes Chart mittels JSON.parse im RAM als Objekt anlagen. Leider gelingt es mir nicht (mehr). Der Inhalt des Datenpunktes mit dem Chart lautet ..

      title: {
        text: 'Tageswerte',
        top: '5%',
        left: '5%',
        textStyle: {
          fontSize: 20,
          fontWeight: 'bold',
          color: '#ffffff'
        },
      },
      legend: {
        data: [
            {
              name: 'Gas',
              itemStyle: {color: '#00ff00'}
            },
            {
              name: 'gH',
              itemStyle: {color: '#ff0000'}
            },
            {
              name: 'gW',
                      itemStyle: {color: '#0000ff'}
            },
            {
              name: 'pH',
              itemStyle: {color: '#ff7f7f'}
            },
            {
              name: 'pW',
              itemStyle: {color: '#7f7fff'}
            }
        ],
        orient: 'vertical',
        right: '10%'
      },
      tooltip: {},
      xAxis: {
        data: ['Gas','gH','gW','pH','pW']
      },
      yAxis: {
        axisLabel: {
          formatter: '{value} KWh',
          align: 'center'
        }
      },
      grid: {
        left: '5%',
        right: '5%',
        top: '15%',
        bottom: '5%'
      },
      series: [
        {
          name: 'Gas',
          type: 'bar',
          stack: 'one',
          data: [{value: 0.81, itemStyle: {color: '#00ff00'}},0,0,0,0]
        },
        {
          name: 'gH',
          type: 'bar',
          stack: 'one',
          data: [0,{value: 66.6, itemStyle: {color: '#ff7f7f'}},0,0,0]
        },
        {
          name: 'gW',
          type: 'bar',
          stack: 'one',
          data: [0,0,{value: 3.9, itemStyle: {color: '#7f7fff'}},0,0]
        },
        {
          name: 'pH',
          type: 'bar',
          stack: 'one',
          data: [0,0,0,{value: 14.9, itemStyle: {color: '#ff0000'}},0]
        },
        {
          name: 'pW',
          type: 'bar',
          stack: 'one',
          data: [0,0,0,0,{value: 1.4, itemStyle: {color: '#0000ff'}}]
        }
      ]
      

      cd93150b-98c5-41b7-9174-8210e32f105c-image.png

      Was mache ich bloß falsch? Muss ich am Ende alle Bezeichner in Anführungszeichen setzen?

      mickym T 2 Replies Last reply Reply Quote 0
      • mickym
        mickym Most Active @legro last edited by

        @legro Ja bei einem sauberen JSON sind die Eigenschaften immer Strings in Anführungszeichen.

        1 Reply Last reply Reply Quote 0
        • T
          ticaki Developer @legro last edited by

          @legro

          hab copilot gesagt er soll mal:

          {
            "title": {
              "text": "Tageswerte",
              "top": "5%",
              "left": "5%",
              "textStyle": {
                "fontSize": 20,
                "fontWeight": "bold",
                "color": "#ffffff"
              }
            },
            "legend": {
              "data": [
                {
                  "name": "Gas",
                  "itemStyle": {"color": "#00ff00"}
                },
                {
                  "name": "gH",
                  "itemStyle": {"color": "#ff0000"}
                },
                {
                  "name": "gW",
                  "itemStyle": {"color": "#0000ff"}
                },
                {
                  "name": "pH",
                  "itemStyle": {"color": "#ff7f7f"}
                },
                {
                  "name": "pW",
                  "itemStyle": {"color": "#7f7fff"}
                }
              ],
              "orient": "vertical",
              "right": "10%"
            },
            "tooltip": {},
            "xAxis": {
              "data": ["Gas", "gH", "gW", "pH", "pW"]
            },
            "yAxis": {
              "axisLabel": {
                "formatter": "{value} KWh",
                "align": "center"
              }
            },
            "grid": {
              "left": "5%",
              "right": "5%",
              "top": "15%",
              "bottom": "5%"
            },
            "series": [
              {
                "name": "Gas",
                "type": "bar",
                "stack": "one",
                "data": [
                  {"value": 0.81, "itemStyle": {"color": "#00ff00"}},
                  0,
                  0,
                  0,
                  0
                ]
              },
              {
                "name": "gH",
                "type": "bar",
                "stack": "one",
                "data": [
                  0,
                  {"value": 66.6, "itemStyle": {"color": "#ff7f7f"}},
                  0,
                  0,
                  0
                ]
              },
              {
                "name": "gW",
                "type": "bar",
                "stack": "one",
                "data": [
                  0,
                  0,
                  {"value": 3.9, "itemStyle": {"color": "#7f7fff"}},
                  0,
                  0
                ]
              },
              {
                "name": "pH",
                "type": "bar",
                "stack": "one",
                "data": [
                  0,
                  0,
                  0,
                  {"value": 14.9, "itemStyle": {"color": "#ff0000"}},
                  0
                ]
              },
              {
                "name": "pW",
                "type": "bar",
                "stack": "one",
                "data": [
                  0,
                  0,
                  0,
                  0,
                  {"value": 1.4, "itemStyle": {"color": "#0000ff"}}
                ]
              }
            ]
          }
          
          L 1 Reply Last reply Reply Quote 1
          • L
            legro @ticaki last edited by

            @ticaki

            Vielen Dank für deine Mühe. Ich habe deinen umgewandelten Text eingegeben, und was soll ich sagen, es funktioniert.👍

            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

            1.0k
            Online

            31.6k
            Users

            79.5k
            Topics

            1.3m
            Posts

            3
            4
            115
            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