JSON reading error

I think I have gremlins in my code this week…

The following should simply read the input values (shown in the comment line) back, but it is showing results of 0 and 5.
JSON is not throwing any errors.

[code]Dim s As String =kjsonexample //{“SecondsFrom1970”:725990405.0,“SecondsFromGMT”:-18000,“IsDST”:false}

Dim jd As New JSONItem(s)
Dim secsGMT As Integer = jd.value(“SecondsFromGMT”).TypeInteger
Dim tz As New Timezone(secsGMT)
Dim secs1970 As Double = jd.value(“SecondsFrom1970”).TypeDouble

Dim dt As New DateTime(secs1970, tz)

//secsGMT = 0
//secs1970 = 5.
//dt = 1970 plus 5 secs

Apparently the problem is trying to read JSON values as something other than Variants. Try changing these two lines

Dim secsGMT As Integer = jd.value("SecondsFromGMT").TypeInteger ... Dim secs1970 As Double = jd.value("SecondsFrom1970").TypeDouble

Dim secsGMT As Integer = jd.value("SecondsFromGMT") ... Dim secs1970 As Double = jd.value("SecondsFrom1970")
They will then be assigned as the appropriate types when assigned to their respective variables.

Brilliant - thank you Dale.

The problem is that TypeInteger and TypeDouble are constants. Substitute with IntegerValue and DoubleValue.

Ah, so it was returning the value of the constants. Understanding now.

If we could go back in time, I’d urge them to adopt some convention for constants to make them easier to distinguish, like “kSomeConstant” or “SOME_CONSTANT”, but that ship has sailed.

Well, a Type is not a Value. If the “Xojo Intelisense” did not autocomplete such constant there, it would help a bit for those not getting it at a glance. Having a Class.Constant ok in this case, but not a Object.Constant.