espace96 / vba-json

Automatically exported from code.google.com/p/vba-json
0 stars 0 forks source link

Spaces improperly removed from object keys #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. use an object key containing a space e.g. "{ ""key with 3 spaces"": 1 }"
2. parse the json
3. key no longer has spaces

What is the expected output? What do you see instead?
JSON object keys should be allowed to have spaces. 

What version of the product are you using? On what operating system?
mac 2011 excel

Please provide any additional information below.

Here is an easy test to illustrate the problem:
1. change the parseKey() func to public
2. run the following test:
Public Sub test()
    Dim s As String, k As String
    Dim j As json
    Set j = New json
    s = """key with spaces"":{""etc..."""
    k = j.parseKey(s, 1)
    Debug.Print "value '" & k & "' should have spaces but does not"
End Sub

This is easily fixed by replacing the parseKey() line below:
            If InStr(vbCrLf & vbCr & vbLf & vbTab & " ", Char) Then
with
            If dquote Or squote Then
                parseKey = parseKey & Char
            ElseIf InStr(vbCrLf & vbCr & vbLf & vbTab & " ", Char) Then

Original issue reported on code.google.com by mewa...@gmail.com on 15 Aug 2014 at 10:31