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

Cannot convert a 2-d array to JSON #8

Open
GoogleCodeExporter opened this issue Jun 12, 2015 · 1 comment
Open

Cannot convert a 2-d array to JSON #8

GoogleCodeExporter opened this issue Jun 12, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a 2-d array, such as: 
Dim arr(0 to 1, 0 to 1) as String
arr(0, 0) = "a"
arr(0, 1) = "b"
arr(1, 0) = "c"
arr(1, 1) = "d"

2. Try to convert to JSON with 
Debug.Print lib.toString(arr)


What is the expected output? What do you see instead?

I expect [["a", "b"], ["c", "d"]]

but I get a "Type Mismatch" error. If I change the array type to Variant, I
get the following: 

[[,],[,]]

but it returns an error.

What version of the product are you using? On what operating system?
json.xls downloaded on 1/15/2010 from the Google Code Site.

Please provide any additional information below.
Thanks for looking into it! 

Original issue reported on code.google.com by [email protected] on 15 Jan 2010 at 10:59

@GoogleCodeExporter
Copy link
Author

One work-around seems to be to use an array of arrays instead of a 2-d array.
Also, arrays seem to need to be of type Variant for this to work.

So     
    Dim arr(0 To 3) As Variant
    arr(0) = "a"
    arr(1) = "b"
    arr(2) = "c"
    arr(3) = "d"

works.

And 

    Dim arr(1 To 2) As Variant
    arr(1) = Array("a", "b")
    arr(2) = Array("c", "d")

works.



Original comment by [email protected] on 14 Oct 2014 at 7:31

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

No branches or pull requests

1 participant