【发布时间】:2018-12-15 16:03:44
【问题描述】:
我有以下 json 字符串:
[
{
"Features": {
"Level": [
{
"endDate": "2018-12-11",
"minimum": "0.000000000000",
"maximum": "0.000000000000",
"value": "228.108000000000",
"payDate": "0"
},
{
"endDate": "2018-12-11",
"minimum": "0.000000000000",
"maximum": "0.000000000000",
"value": "3143.513000000000",
"payDate": "0"
}
]
}
},
]
我试图使用 vba 在 excel 中提取这两个值并具有以下代码(其中 result2 将是 json 字符串)
Public Sub GetS (result2 As String, m As Integer)
Dim activeWS As Worksheet
Set activeWS = ThisWorkbook.Worksheets("Data")
Dim jsonStr As String, json As Object, headers()
jsonStr = result2
Set json = JsonConverter.ParseJson(jsonStr)(1)
activeWS.Cells(m, 19) = json("Features")("Level")(0)("value")
activeWS.Cells(m, 20) = json("Features")("Level")(1)("value")
End Sub
vba 的第二部分工作,它获取 3143.51(第二个数字)的值,我想知道如何获得第一个值 (228.10)。
我尝试过使用 ("Initial Level")(0)("value") 但它不起作用。
非常感谢。
【问题讨论】: