@@ -221,6 +221,23 @@ Private Declare Sub json_CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
221
221
(json_MemoryDestination As Any , json_MemorySource As Any , ByVal json_ByteLength As Long )
222
222
223
223
#End If
224
+
225
+ Private Type json_Options
226
+ ' VBA only stores 15 significant digits, so any numbers larger than that are truncated
227
+ ' This can lead to issues when BIGINT's are used (e.g. for Ids or Credit Cards), as they will be invalid above 15 digits
228
+ ' See: http://support.microsoft.com/kb/269370
229
+ '
230
+ ' By default, VBA-JSON will use String for numbers longer than 15 characters that contain only digits
231
+ ' to override set `JsonConverter.JsonOptions.UseDoubleForLargeNumbers = True`
232
+ UseDoubleForLargeNumbers As Boolean
233
+
234
+ ' The JSON standard requires object keys to be quoted (" or '), use this option to allow unquoted keys
235
+ AllowUnquotedKeys As Boolean
236
+
237
+ ' The solidus (/) is not required to be escaped, use this option to escape them as \/ in ConvertToJson
238
+ EscapeSolidus As Boolean
239
+ End Type
240
+ Public JsonOptions As json_Options
224
241
' === End VBA-JSON
225
242
226
243
#If Mac Then
@@ -1767,7 +1784,7 @@ Private Function web_GetUrlEncodedKeyValue(Key As Variant, Value As Variant) As
1767
1784
End Function
1768
1785
1769
1786
''
1770
- ' VBA-JSON v2.0.0
1787
+ ' VBA-JSON v2.0.1
1771
1788
' (c) Tim Hall - https://github.com/VBA-tools/VBA-JSON
1772
1789
'
1773
1790
' JSON Converter for VBA
@@ -1813,23 +1830,6 @@ End Function
1813
1830
1814
1831
' (Declarations moved to top)
1815
1832
1816
- Private Type json_Options
1817
- ' VBA only stores 15 significant digits, so any numbers larger than that are truncated
1818
- ' This can lead to issues when BIGINT's are used (e.g. for Ids or Credit Cards), as they will be invalid above 15 digits
1819
- ' See: http://support.microsoft.com/kb/269370
1820
- '
1821
- ' By default, VBA-JSON will use String for numbers longer than 15 characters that contain only digits
1822
- ' to override set `JsonConverter.JsonOptions.UseDoubleForLargeNumbers = True`
1823
- UseDoubleForLargeNumbers As Boolean
1824
-
1825
- ' The JSON standard requires object keys to be quoted (" or '), use this option to allow unquoted keys
1826
- AllowUnquotedKeys As Boolean
1827
-
1828
- ' The solidus (/) is not required to be escaped, use this option to escape them as \/ in ConvertToJson
1829
- EscapeSolidus As Boolean
1830
- End Type
1831
- Public JsonOptions As json_Options
1832
-
1833
1833
' ============================================= '
1834
1834
' Public Methods
1835
1835
' ============================================= '
@@ -1901,7 +1901,7 @@ Public Function ConvertToJson(ByVal json_DictionaryCollectionOrArray As Variant)
1901
1901
ConvertToJson = """" & json_DateStr & """"
1902
1902
Case VBA.vbString
1903
1903
' String (or large number encoded as string)
1904
- If Not JsonConverter. JsonOptions.UseDoubleForLargeNumbers And json_StringIsLargeNumber(json_DictionaryCollectionOrArray) Then
1904
+ If Not JsonOptions.UseDoubleForLargeNumbers And json_StringIsLargeNumber(json_DictionaryCollectionOrArray) Then
1905
1905
ConvertToJson = json_DictionaryCollectionOrArray
1906
1906
Else
1907
1907
ConvertToJson = """" & json_Encode(json_DictionaryCollectionOrArray) & """"
@@ -2172,7 +2172,7 @@ Private Function json_ParseNumber(json_String As String, ByRef json_Index As Lon
2172
2172
' See: http://support.microsoft.com/kb/269370
2173
2173
'
2174
2174
' Fix: Parse -> String, Convert -> String longer than 15 characters containing only numbers and decimal points -> Number
2175
- If Not JsonConverter. JsonOptions.UseDoubleForLargeNumbers And Len(json_Value) >= 16 Then
2175
+ If Not JsonOptions.UseDoubleForLargeNumbers And Len(json_Value) >= 16 Then
2176
2176
json_ParseNumber = json_Value
2177
2177
Else
2178
2178
' VBA.Val does not use regional settings, so guard for comma is not needed
@@ -2187,7 +2187,7 @@ Private Function json_ParseKey(json_String As String, ByRef json_Index As Long)
2187
2187
' Parse key with single or double quotes
2188
2188
If VBA.Mid$(json_String, json_Index, 1 ) = """" Or VBA.Mid$(json_String, json_Index, 1 ) = "'" Then
2189
2189
json_ParseKey = json_ParseString(json_String, json_Index)
2190
- ElseIf JsonConverter. JsonOptions.AllowUnquotedKeys Then
2190
+ ElseIf JsonOptions.AllowUnquotedKeys Then
2191
2191
Dim json_Char As String
2192
2192
Do While json_Index > 0 And json_Index <= Len(json_String)
2193
2193
json_Char = VBA.Mid$(json_String, json_Index, 1 )
@@ -2243,7 +2243,7 @@ Private Function json_Encode(ByVal json_Text As Variant) As String
2243
2243
json_Char = "\\"
2244
2244
Case 47
2245
2245
' / -> 47 -> \/ (optional)
2246
- If JsonConverter. JsonOptions.EscapeSolidus Then
2246
+ If JsonOptions.EscapeSolidus Then
2247
2247
json_Char = "\/"
2248
2248
End If
2249
2249
Case 8
0 commit comments