您好,在我成功將元資料決議為 excel 之后,我現在面臨將其決議回與 Cardano 區塊鏈兼容的 Metadata.JSON 的挑戰
但不幸的是我無法適應正確的元資料結構
那應該是這樣的:
{
"721": {
"policy": {
"tokenname": {
"country": "1",
"test": "123"
},
"tokenname": {
"country": "1",
"test": "123"
}
}
}
}
這就是我目前的狀態: 我的代碼和結果
Sub live_json()
Dim rng As Range, items As New Collection, myitem As New Dictionary, subitem As New Dictionary, i As Integer, cell As Variant
'Set rng = Range("A2:A3")
'Set rng = Range(Sheets(2).Range("A2"), Sheets(2).Range("A2").End(xlDown)) use this for dynamic range
Set abc = New Collection
abc.Add ("721")
For a = 0 To 2
subitem("country") = "123"
subitem("test") = "123"
myitem.Add "tokenname", subitem
items.Add myitem
Set myitem = Nothing
Set subitem = Nothing
Next
abc.Add items
MsgBox (ConvertToJson(abc, Whitespace:=2))
End Sub
我想我快到了
uj5u.com熱心網友回復:
這對我有用:
Sub live_json()
Dim root As Dictionary, k As Dictionary, a As Long
Set root = New Dictionary
Set k = New Dictionary
root.Add "721", k
k.Add "policy", New Dictionary
Set k = k("policy")
For a = 0 To 2
k.Add "tokenname" & a, New Dictionary
With k("tokenname" & a)
.Add "country", "1"
.Add "test", "123"
End With
Next
Debug.Print ConvertToJson(root, Whitespace:=2)
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/382717.html
