VBA JsonParser clsJsonParser不工作

VBA JsonParser clsJsonParser不工作,json,ms-access,vba,Json,Ms Access,Vba,我用刮痧做了一只蜘蛛。我运行它并将输出保存在json文件中,如下所示。然后我在VBA中使用clsJsonParser,代码如下。但是我在element.item(“newstxt”)中得到了一个3265错误“element未在此集合中找到”;而element.item(“newsttitle”)工作正常。出什么事了?这是我的VBA代码,还是json文件的格式 Public Sub JSONImport() Dim coll As Collection Dim json As New clsJSO

我用刮痧做了一只蜘蛛。我运行它并将输出保存在json文件中,如下所示。然后我在VBA中使用clsJsonParser,代码如下。但是我在element.item(“newstxt”)中得到了一个3265错误“element未在此集合中找到”;而element.item(“newsttitle”)工作正常。出什么事了?这是我的VBA代码,还是json文件的格式

Public Sub JSONImport()
Dim coll As Collection
Dim json As New clsJSONparser
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim element As Variant

Dim FileNum As Integer
Dim DataLine As String, jsonStr As String

' READ FROM EXTERNAL FILE
FileNum = FreeFile()
Open "C:\Users\Philippe\sfo\unepinquiry\items.json" For Input As #FileNum

' PARSE FILE STRING
jsonStr = ""
While Not EOF(FileNum)
    Line Input #FileNum, DataLine

    jsonStr = jsonStr & DataLine & vbNewLine
Wend
Close #FileNum

    Set db = CurrentDb
    Set rs = db.OpenRecordset("News_1", dbOpenDynaset, dbSeeChanges)
    Set coll = json.parse(jsonStr)

    For Each element In coll
        rs.AddNew
        rs!newstitle = element.item("newstitle")
        rs!newstxt = element.item("newstxt")
        rs.Update
    Next


Set element = Nothing
Set coll = Nothing
端接头

[{“newstxt”:["2016年6月21日,二十国集团绿色金融研究小组第四次会议在厦门举行,会议由中国人民银行和英格兰银行联席主席主持,来自二十国集团国家、受邀客源国和国际组织的代表参加了会议,代表们进行了讨论,原则上达成一致关于G20绿色金融综合报告,该报告将提交给6月的G20财政和央行代表厦门会议。研究小组将进一步修订该报告,并提交给7月的G20财政部长和央行行长成都会议。”],“新闻标题”:\G20绿色金融研究小组第三次会议在厦门闭幕, {“newstxt”:[“孟买,2016年4月29日\u00a0-印度为包容性和可持续发展制定了雄心勃勃的目标,这需要动员更多的低成本长期资本。联合国环境规划署(环境署)和印度工商会联合会(FICCI)今天发布了一份新报告展示了印度如何引进创新方法来吸引私人资本投资绿色资产,并概述了印度深化这一进程的一些关键步骤。”],“newstitle”:“\n新报告展示了印度如何扩大可持续金融规模”}]


无法判断,但如果运行此测试函数:

Public Sub TestJsonText()

    Dim DataCollection      As Collection
    Dim ResponseText        As String

    ResponseText = _
        "[{""newstxt"": [""On June 21, 2016, the fourth meeting of the G20 Green Finance Study Group was held in Xiamen. The meeting was hosted by Co-chairs from the People's Bank of China and the Bank of England. Delegates from G20 countries, invited guest countries and International Organizations participated in the meeting. The delegates discussed and agreed in principle on the G20 Green Finance Synthesis Report, which would be submitted to the June G20 Finance and Central Bank Deputies Xiamen Meeting. The study group will further revise and submit the Report to the July G20 Finance Ministers and Central Bank Governors Chengdu Meeting.""]," & _
        """newstitle"": ""\nFourth Meeting of the G20 Green Finance Study Group Concludes in Xiamen\n""}, " & _
        "{""newstxt"": [""Mumbai, 29 April 2016\u00a0- India has set ambitious goals for inclusive and sustainable development, which require the mobilization of additional low-cost, long-term capital. A new report launched today by the United Nations Environment Programme (UNEP) and the Federation of Indian Chambers of Commerce and Industry (FICCI) shows how the country is already introducing innovative approaches to attract private capital for green assets - and outlines a number of key steps to deepen this process in India.""]," & _
        """newstitle"": ""\nNew Report Shows How India Can Scale up Sustainable Finance\n""}]"
    If ResponseText <> "" Then
        Set DataCollection = CollectJson(ResponseText)
        MsgBox "Retrieved" & Str(DataCollection.Count) & " root member(s)", vbInformation + vbOKOnly, "Web Service Success"
    End If

    Call ListFieldNames(DataCollection)

    Set DataCollection = Nothing

End Sub
在我看来这是正确的,所以你必须调查一下

root                        
    0                       
        newstxt             On June 21, 2016, the fourth meeting of the G20 Green Finance Study Group was held in Xiamen. The meeting was hosted by Co-chairs from the People's Bank of China and the Bank of England. Delegates from G20 countries, invited guest countries and International Organizations participated in the meeting. The delegates discussed and agreed in principle on the G20 Green Finance Synthesis Report, which would be submitted to the June G20 Finance and Central Bank Deputies Xiamen Meeting. The study group will further revise and submit the Report to the July G20 Finance Ministers and Central Bank Governors Chengdu Meeting.
        newstitle           
Fourth Meeting of the G20 Green Finance Study Group Concludes in Xiamen

    1                       
        newstxt             Mumbai, 29 April 2016 - India has set ambitious goals for inclusive and sustainable development, which require the mobilization of additional low-cost, long-term capital. A new report launched today by the United Nations Environment Programme (UNEP) and the Federation of Indian Chambers of Commerce and Industry (FICCI) shows how the country is already introducing innovative approaches to attract private capital for green assets - and outlines a number of key steps to deepen this process in India.
        newstitle           
New Report Shows How India Can Scale up Sustainable Finance