0

I want to parse an json element that consists of an "array". In this case solar->solardata->calculatedconditions->band[0-7] How can i do this?

My attempt was:

String data = root["solar"]["solardata"]["calculatedconditions"]["band"][0]["#text"];

But it returns NIL

Plattform: ESP8266

Library: ArduinoJson

{
   "solar":{
      "solardata":{
         "source":{
            "@url":"http://www.hamqsl.com/solar.html",
            "#text":"N0NBH"
         },
         "updated":"11 Jun 2017 2032 GMT",
         "solarflux":"75",
         "aindex":"4",
         "kindex":"5",
         "kindexnt":"No Report",
         "xray":"A6.8",
         "sunspots":"0",
         "heliumline":"107.7",
         "protonflux":"1.40e-01",
         "electonflux":"9.37e+01",
         "aurora":"2",
         "normalization":"1.99",
         "latdegree":"66.5",
         "solarwind":"416.2",
         "magneticfield":"-2.4",
         "calculatedconditions":{
            "band":[
               {
                  "@name":"80m-40m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"30m-20m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"17m-15m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"12m-10m",
                  "@time":"day",
                  "#text":"Poor"
               },
               {
                  "@name":"80m-40m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"30m-20m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"17m-15m",
                  "@time":"night",
                  "#text":"Poor"
               },
               {
                  "@name":"12m-10m",
                  "@time":"night",
                  "#text":"Poor"
               }
            ]
         },
         "calculatedvhfconditions":{
            "phenomenon":[
               {
                  "@name":"vhf-aurora",
                  "@location":"northern_hemi",
                  "#text":"Band Closed"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe",
                  "#text":"144MHz ES"
               },
               {
                  "@name":"E-Skip",
                  "@location":"north_america",
                  "#text":"Band Closed"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe_6m",
                  "#text":"50MHz ES"
               },
               {
                  "@name":"E-Skip",
                  "@location":"europe_4m",
                  "#text":"70MHz ES"
               }
            ]
         },
         "geomagfield":"MIN STRM",
         "signalnoise":"S4-S6",
         "fof2":"NoRpt",
         "muffactor":"NoRpt",
         "muf":"NoRpt"
      }
   }
}

closed as off-topic by jose can u c, TisteAndii, SDsolar, user31481, Code Gorilla Aug 16 '17 at 15:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – SDsolar, Community, Code Gorilla
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I'm voting to close this question as off-topic because the submitter solved the problem him/herself by finding their own mistake. – jose can u c Aug 15 '17 at 17:56
  • Id found many people with almost the same problem. Its an problem related to ArduinoJson. You should try to find out if theres a space in the beginning of the json array. Your browser wont show you that. Id found the spaces while enabling Developer mode in Firefox. How can i close this question? I wont close it as off-topic - because its not. – Gamecompiler Aug 16 '17 at 9:15
1

My code was correct. The problem was that the json array contained an " " as first character. Thats why the parsing failed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.