Skip to content

Commit 4f80c6c

Browse files
authored
Update JSON.bas v1.71
Fixed YAML converter indentation chars to 2 spaces instead of Tab.
1 parent 225a8e2 commit 4f80c6c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

JSON.bas

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Attribute VB_Name = "JSON"
22

3-
' VBA JSON parser, Backus-Naur form JSON parser based on RegEx v1.7
4-
' Copyright (C) 2015-2018 omegastripes
3+
' VBA JSON parser, Backus-Naur form JSON parser based on RegEx v1.71
4+
' Copyright (C) 2015-2019 omegastripes
55
66
' https://github.com/omegastripes/VBA-JSON-parser
77
'
@@ -249,26 +249,26 @@ Private Sub SerializeElement(vElement As Variant, ByVal sIndent As String)
249249

250250
End Sub
251251

252-
Function ToString(vJSON As Variant) As String
252+
Function ToYaml(vJSON As Variant) As String
253253

254254
Select Case VarType(vJSON)
255255
Case vbObject, Is >= vbArray
256256
Set oChunks = CreateObject("Scripting.Dictionary")
257-
ToStringElement vJSON, ""
257+
ToYamlElement vJSON, ""
258258
oChunks.Remove 0
259-
ToString = Join(oChunks.Items(), "")
259+
ToYaml = Join(oChunks.Items(), "")
260260
Set oChunks = Nothing
261261
Case vbNull
262-
ToString = "Null"
262+
ToYaml = "Null"
263263
Case vbBoolean
264-
ToString = IIf(vJSON, "True", "False")
264+
ToYaml = IIf(vJSON, "True", "False")
265265
Case Else
266-
ToString = CStr(vJSON)
266+
ToYaml = CStr(vJSON)
267267
End Select
268268

269269
End Function
270270

271-
Private Sub ToStringElement(vElement As Variant, ByVal sIndent As String)
271+
Private Sub ToYamlElement(vElement As Variant, ByVal sIndent As String)
272272

273273
Dim aKeys() As Variant
274274
Dim i As Long
@@ -283,7 +283,7 @@ Private Sub ToStringElement(vElement As Variant, ByVal sIndent As String)
283283
aKeys = vElement.Keys
284284
For i = 0 To UBound(aKeys)
285285
.Item(.Count) = sIndent & aKeys(i) & ": "
286-
ToStringElement vElement(aKeys(i)), sIndent & vbTab
286+
ToYamlElement vElement(aKeys(i)), sIndent & " "
287287
If Not (i = UBound(aKeys)) Then .Item(.Count) = vbCrLf
288288
Next
289289
End If
@@ -294,7 +294,7 @@ Private Sub ToStringElement(vElement As Variant, ByVal sIndent As String)
294294
.Item(.Count) = vbCrLf
295295
For i = 0 To UBound(vElement)
296296
.Item(.Count) = sIndent & i & ": "
297-
ToStringElement vElement(i), sIndent & vbTab
297+
ToYamlElement vElement(i), sIndent & " "
298298
If Not (i = UBound(vElement)) Then .Item(.Count) = vbCrLf
299299
Next
300300
End If

0 commit comments

Comments
 (0)