Skip to content
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

Open
jpmbiz70 opened this issue Sep 7, 2023 · 5 comments
Open

Will no process leading/trailing JSON brackets [] #254

jpmbiz70 opened this issue Sep 7, 2023 · 5 comments

Comments

@jpmbiz70
Copy link

jpmbiz70 commented Sep 7, 2023

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.

@Nick-vanGemeren
Copy link

The JSON array [a,b,c ...] is a (possibly empty) list of JSON values, not necessarily JSON objects.
It's not clear what your issue is. Can you post a simple code example which reproduces the problem?

@TomasDohnal7
Copy link

The error can be reproduced, if you try to parse JSON:
{ "_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" }

@Nick-vanGemeren
Copy link

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.

@jpmbiz70
Copy link
Author

jpmbiz70 commented Sep 12, 2023 via email

@Nick-vanGemeren
Copy link

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'.
If you parse the string with the VBA Debugger, which code line in which sub/function raises the 424 error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants