I am trying to parse json and things are not working quite correctly...
I have this json code, which from some stock information retrieval api:
{
"Meta Data": {
"1. Information": "Daily Time Series with Splits and Dividend Events",
"2. Symbol": "UNG",
"3. Last Refreshed": "2018-01-29",
"4. Output Size": "Full size",
"5. Time Zone": "US/Eastern"
},
"Time Series (Daily)": {
"2018-01-29": {
"1. open": "26.0700",
"2. high": "26.9000",
"3. low": "26.0400",
"4. close": "26.8400",
"5. adjusted close": "26.8400",
"6. volume": "7056837",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-26": {
"1. open": "26.7500",
"2. high": "27.0000",
"3. low": "26.6700",
"4. close": "26.7700",
"5. adjusted close": "26.7700",
"6. volume": "6329877",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-25": {
"1. open": "26.2800",
"2. high": "26.7600",
"3. low": "25.9800",
"4. close": "26.1700",
"5. adjusted close": "26.1700",
"6. volume": "6235136",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-24": {
"1. open": "26.0500",
"2. high": "26.4400",
"3. low": "25.5400",
"4. close": "25.7200",
"5. adjusted close": "25.7200",
"6. volume": "7197720",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-23": {
"1. open": "25.6200",
"2. high": "26.4200",
"3. low": "25.4400",
"4. close": "25.9400",
"5. adjusted close": "25.9400",
"6. volume": "7943240",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-22": {
"1. open": "24.6500",
"2. high": "24.8800",
"3. low": "24.5800",
"4. close": "24.8500",
"5. adjusted close": "24.8500",
"6. volume": "3674144",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
"2018-01-19": {
"1. open": "25.0000",
"2. high": "25.3200",
"3. low": "24.7250",
"4. close": "24.8600",
"5. adjusted close": "24.8600",
"6. volume": "4292913",
"7. dividend amount": "0.0000",
"8. split coefficient": "1.0000"
},
}
I created the following classes because I wanted to be able to deserialize the json into the following objects...
Public Class JJSON
Public json As JSON_Container
End Class
Public Class MetaData
<JsonProperty(PropertyName:="1. Information")>
Public Property information
<JsonProperty(PropertyName:="2. Symbol")>
Public Property symbol
<JsonProperty(PropertyName:="3. Last Refreshed")>
Public Property last_refreshed
<JsonProperty(PropertyName:="4. Output Size")>
Public Property output_size
<JsonProperty(PropertyName:="5. Time Zone")>
Public Property time_zone
End Class
Public Class JSON_Container
<JsonProperty(PropertyName:="Meta Data")>
Private Meta As MetaData
<JsonProperty(PropertyName:="Time Series (Daily)")>
Public Time_Series_Daily As StockDate
End Class
Public Class StockDate
Public Dt As List(Of StockInfo)
End Class
Public Class StockInfo
<JsonProperty(PropertyName:="1. open")>
Public Property open As String
<JsonProperty(PropertyName:="2. high")>
Public Property high As String
<JsonProperty(PropertyName:="3. low")>
Public Property low As String
<JsonProperty(PropertyName:="4. close")>
Public Property close As String
<JsonProperty(PropertyName:="5. adjusted close")>
Public Property adjusted_close As String
<JsonProperty(PropertyName:="6. volume")>
Public Property volume As String
<JsonProperty(PropertyName:="7. dividend amount")>
Public Property dividend_amount As String
<JsonProperty(PropertyName:="8. split coefficient")>
Public Property split_coefficient As String
End Class
And, when I execute this code:
Dim obj1 = JsonConvert.DeserializeObject(Of JSON_Container)(json)
It works partially since only the "Meta Data" gets parsed correctly. I have tried everything I could think of at this point.
Any help would be appreciated..