BarryCambridge
New member
- Local time
- Yesterday, 16:22
- Joined
- Mar 10, 2017
- Messages
- 6
I've been struggling to get the VBA-JSON parser to work for me and while I can see others have had the same problem, I can't find how it was fixed.
Sorry - I don't have sufficient posts to put links in my posts, but searching VBA-JSON will take you to GitHub and the source code for the parser module
It seems to be down to the structure of my JSON file which comes from a Gravity Forms Module in WordPress. I can import the file ok and pass it to the parser, but when I set a Watch to see what ends up in "coll", I see Item 1 "status, Item 2 "response" and then it seems to ignore the rest of the file containing the variables I actually want to add to my table! I think it's down to the positioning of the { and [ brackets.
The start of the JSON file I get is :
{"status":200,"response":{"total_count":"13","entries":[{"id":"699","form_id":"3","post_id":null,"date_created":"2018-09-01 06:33:23","date_updated":null,"is_starred":"0","is_read":"0","ip":"xxxxxx","source_url":"https:\/\removed for post\/register-your-interest ………………..
The tutorial I have used says the parser will return a Dictionary or Collection depending on what it finds. If I delclare "coll" as a dictionary, it works as above. If I declare it as a Collection, I get a Type Miss Match Error.
As you can probably tell, I'm no expert, so I hope this makes some sort of sense and any pointers would be much appreciated. It's a bit frustrating to have it so nearly working!
Many thanks, Barry
Sorry - I don't have sufficient posts to put links in my posts, but searching VBA-JSON will take you to GitHub and the source code for the parser module
It seems to be down to the structure of my JSON file which comes from a Gravity Forms Module in WordPress. I can import the file ok and pass it to the parser, but when I set a Watch to see what ends up in "coll", I see Item 1 "status, Item 2 "response" and then it seems to ignore the rest of the file containing the variables I actually want to add to my table! I think it's down to the positioning of the { and [ brackets.
The start of the JSON file I get is :
{"status":200,"response":{"total_count":"13","entries":[{"id":"699","form_id":"3","post_id":null,"date_created":"2018-09-01 06:33:23","date_updated":null,"is_starred":"0","is_read":"0","ip":"xxxxxx","source_url":"https:\/\removed for post\/register-your-interest ………………..
The tutorial I have used says the parser will return a Dictionary or Collection depending on what it finds. If I delclare "coll" as a dictionary, it works as above. If I declare it as a Collection, I get a Type Miss Match Error.
As you can probably tell, I'm no expert, so I hope this makes some sort of sense and any pointers would be much appreciated. It's a bit frustrating to have it so nearly working!
Many thanks, Barry
Code:
Public Function ParseWordpressData()
Dim httpReq As New MSXML2.ServerXMLHTTP
Dim coll As Dictionary
Dim db As DAO.Database
Dim rs As DAO.Recordset
httpReq.Open "GET", "etc, etc
httpReq.send
Debug.Print httpReq.responseText
If httpReq.status = 200 Then
Set coll = JsonConverter.ParseJson(httpReq.responseText)
'Debug.Print JsonConverter.ConvertToJson(coll, Whitespace:=2)
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_wordpress_api", dbOpenDynaset, dbSeeChanges)