Skip to content

Change suggested for "json_StringIsLargeNumber" function to detect multiple dots #283

@ricardo-hz-sz

Description

@ricardo-hz-sz

Hi,

json_StringIsLargeNumber return true with strings with more than one dot: "2025.07.16.00.00"

I suggest this change to return False when code detects multiple dots.

Private Function json_StringIsLargeNumber(json_String As Variant) As Boolean
' Check if the given string is considered a "large number"
' (See json_ParseNumber)

Dim json_Length As Long
Dim json_CharIndex As Long
json_Length = VBA.Len(json_String)

' Length with be at least 16 characters and assume will be less than 100 characters
If json_Length >= 16 And json_Length <= 100 Then
    Dim json_CharCode As String
    Dim dotsFound As Long

    json_StringIsLargeNumber = True        
    dotsFound = 0

    For json_CharIndex = 1 To json_Length
        json_CharCode = VBA.Asc(VBA.Mid$(json_String, json_CharIndex, 1))
        Select Case json_CharCode
        ' Look for .|0-9|E|e
        Case 46
            If dotsFound > 0 Then
                json_StringIsLargeNumber = False
                Exit Function
            End If
            dotsFound = dotsFound + 1

        Case 48 To 57, 69, 101
            ' Continue through characters
        Case Else
            json_StringIsLargeNumber = False
            Exit Function
        End Select
    Next json_CharIndex
End If

End Function

Thanks for this excellent software

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions