-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Will no process leading/trailing JSON brackets [] #254
Comments
The JSON array [a,b,c ...] is a (possibly empty) list of JSON values, not necessarily JSON objects. |
The error can be reproduced, if you try to parse JSON: |
I did ask for a code example, not just the long input string.
... using VBA-JSON v2.3.2, runs without problems and prints as expected:
Did you remember that you need a Set command to receive the object returned by ParseJson? If the above solves your problem, please close the issue. |
if str = "[{ ""_Issues"": ""Issues"", ""description"": ""description"", ""id"": ""123"", " _
& " ""milestonesList"": """", ""modulesList"": ""Module1"", ""priority"": """", " _
& " ""projects"": [ { } ], ""projectsNamesList"": ""affas"", " _
& " ""requirementsEstimate"": """", " _
& " ""requirementsID"": ""2977"", ""requirementsLevel1"": ""Req1"", " _
& " ""requirementsLevel2"": ""Req2"", ""requirementsLevel3"": ""blavla zak\u00e1zat"", " _
& " ""requirementsProjectName"": ""Future"", ""requirementsState"": ""Sleeping"", " _
& " ""requirementsTitle"": ""Something zak\u00e1zat"", ""sprint"": "".4-Someday"", " _
& " ""state"": ""Sleeping"", ""typeB"": ""Suggestion"" }] "
It will fail. brackets need to be processed according to spec. Other tools like https://beautifytools.com/ will parse with brackets properly. But, I'm not sure if this is a MS issue or an issue with VBA-JSON.
Regards,
James
…________________________________
From: Nick van Gemeren ***@***.***>
Sent: Tuesday, September 12, 2023 7:42 AM
To: VBA-tools/VBA-JSON ***@***.***>
Cc: James ***@***.***>; Author ***@***.***>
Subject: Re: [VBA-tools/VBA-JSON] Will no process leading/trailing JSON brackets [] (Issue #254)
I did ask for a code example, not just the long input string.
This routine:
Sub Issue254()
Dim str As String
Dim result As Object
str = "{ ""_Issues"": ""Issues"", ""description"": ""description"", ""id"": ""123"", " _
& " ""milestonesList"": """", ""modulesList"": ""Module1"", ""priority"": """", " _
& " ""projects"": [ { } ], ""projectsNamesList"": ""affas"", " _
& " ""requirementsEstimate"": """", " _
& " ""requirementsID"": ""2977"", ""requirementsLevel1"": ""Req1"", " _
& " ""requirementsLevel2"": ""Req2"", ""requirementsLevel3"": ""blavla zak\u00e1zat"", " _
& " ""requirementsProjectName"": ""Future"", ""requirementsState"": ""Sleeping"", " _
& " ""requirementsTitle"": ""Something zak\u00e1zat"", ""sprint"": "".4-Someday"", " _
& " ""state"": ""Sleeping"", ""typeB"": ""Suggestion"" } "
Set result = ParseJson(str)
Debug.Print ConvertToJson(result, 2)
End Sub
... using VBA-JSON v2.3.2, runs without problems and prints as expected:
{
"_Issues": "Issues",
"description": "description",
"id": "123",
"milestonesList": "",
"modulesList": "Module1",
"priority": "",
"projects": [
{
}
],
"projectsNamesList": "affas",
"requirementsEstimate": "",
"requirementsID": "2977",
"requirementsLevel1": "Req1",
"requirementsLevel2": "Req2",
"requirementsLevel3": "blavla zak\u00E1zat",
"requirementsProjectName": "Future",
"requirementsState": "Sleeping",
"requirementsTitle": "Something zak\u00E1zat",
"sprint": ".4-Someday",
"state": "Sleeping",
"typeB": "Suggestion"
}
Did you remember that you need a Set command to receive the object returned by ParseJson?
If the above solves your problem, please close the issue.
—
Reply to this email directly, view it on GitHub<#254 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AH5ESYMYCORVS4EP3GYPO5DX2BKDZANCNFSM6AAAAAA4POVN7I>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Using your string (or adding surrounding square brackets to the original) to the test routine I posted earlier gives expected results on my system. Are you on a Mac or using Dictionary.cls? 'It will fail' is as unhelpful as 'It doesn't work'. |
JSON spec includes a leading/trailing bracket. It is an array of objects. Subsequently, Microsoft VBA throws a "Run-time error '424: Object required" error. If I remove the leading/trailing brackets it works fine. This either appears to be a bug in VBA for Excel or this tool.
The text was updated successfully, but these errors were encountered: