Announcement

Collapse
No announcement yet.

Weather (YR / met.no) script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by widert View Post
    As far as I can read from the above then RGE had the same issues, but solved them.
    I don't see that, what post do you refer to?
    Also, the error you mention - what line of code exactly is causing it?

    Comment


      #17
      Originally posted by widert View Post
      As far as I can read from the above then RGE had the same issues, but solved them.
      Just try something simple, i.e. just
      Code:
      Public Class Weather
         Public Property type As String
      End Class

      Comment


        #18
        Where there are classes/properties in the JSON with the same name the generated code is missing lines and/or it messes up the get/set parts.

        I can't remember the full details, but looking at my script I have these bits among the rest which are probably the relevant parts:

        Code:
        Public Class Details2
            Public Property precipitation_amount as Double
        End Class
        
        Public Class Next1Hours
            Public Property summary As Summary
            Public Property details As Details2
        End Class
        There may be other parts, but that's the general idea - each class should have the same properties as the corresponding part of JSON; the class names don't matter, hence the freedom to create a new distinct "Details2" class to represent that slightly different details element.

        Comment


          #19
          If necessary you can also use attribute to change the property name, i.e. if there's a space in json name:
          Code:
          [JsonProperty("time stamp")]
          public UInt64 TimeStamp { get; set; }

          Comment


            #20
            Originally posted by alexbk66 View Post

            Just try something simple, i.e. just
            Code:
            Public Class Weather
            Public Property type As String
            End Class
            So, testing something simple:
            Code:
            Sub Main(parm as object)
              Dim test as weather
            End Sub
            Public Class Weather
               Public Property type As String
            End Class
            Gives me the following errors:


            Click image for larger version

Name:	Capture.PNG
Views:	71
Size:	119.3 KB
ID:	1459096

            Comment


              #21
              widert so it's definitely Mono version issue, please Google. May be try updating to latest version (6.12?).
              In the worst case you'll have to add setters and getters to each property explicitly.

              Comment


                #22
                I did some testing with Mono, using vnbc, and interestingly by removing "Property" it is actually working.

                So hence, the class now looks like:

                Code:
                Public Class Geometry
                  Public type As String
                  Public coordinates As Double()
                End Class
                Public Class Units
                  Public air_pressure_at_sea_level As String
                  Public air_temperature As String
                  Public cloud_area_fraction As String
                  Public precipitation_amount As String
                  Public relative_humidity As String
                  Public wind_from_direction As String
                  Public wind_speed As String
                End Class
                Public Class Meta
                  Public updated_at As DateTime
                  Public units As Units
                End Class
                Public Class Details
                  Public air_pressure_at_sea_level As Double
                  Public air_temperature As Double
                  Public cloud_area_fraction As Double
                  Public dew_point_temperature As Double
                  Public relative_humidity As Double
                  Public wind_from_direction As Double
                  Public wind_speed As Double
                End Class
                Public Class Details2
                  Public precipitation_amount as Double
                End Class
                Public Class Instant
                  Public details As Details
                End Class
                Public Class Summary
                  Public symbol_code As String
                End Class
                Public Class Next12Hours
                  Public summary As Summary
                End Class
                Public Class Next1Hours
                  Public summary As Summary
                  Public details As Details2
                End Class
                Public Class Next6Hours
                  Public summary As Summary
                  Public details As Details2
                End Class
                Public Class Data
                  Public instant As Instant
                  Public next_12_hours As Next12Hours
                  Public next_1_hours As Next1Hours
                  Public next_6_hours As Next6Hours
                End Class
                Public Class Timesery
                  Public time As DateTime
                  Public data As Data
                End Class
                Public Class Properties
                  Public meta As Meta
                  Public timeseries As Timesery()
                End Class
                Public Class Weather
                  Public type As String
                  Public geometry As Geometry
                  Public properties As Properties
                End Class
                Thank you very much for your help and guidance, really appreciate it!

                Comment


                  #23
                  Interesting...

                  Comment

                  Working...
                  X