Last active
August 2, 2021 22:47
-
-
Save jim-oflaherty-jr-qalocate-com/0e2387a851c117919ae0580df3aae78d to your computer and use it in GitHub Desktop.
JSON Properties Fetch Value from JSON Path...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Const JSON_SEPARATOR_ROW As String = vbLf 'Character: Carriage Return | |
Public Const JSON_SEPARATOR_KEY_VALUE As String = vbTab 'Character: TAB | |
Public Function fetchFromJsonPath( _ | |
ByVal jsonAsPathsToValues As String _ | |
, ByVal jsonPath As String _ | |
) As String | |
Dim result As String | |
Dim key As String | |
Dim indexStart As Long | |
Dim indexEnd As Long | |
If (LenB(jsonAsPathsToValues) <> 0) Then | |
If (LenB(jsonPath) <> 0) Then | |
key = JSON_SEPARATOR_ROW + LCase$(jsonPath) + JSON_SEPARATOR_KEY_VALUE | |
indexStart = InStr(jsonAsPathsToValues, key) | |
If (indexStart > 0) Then | |
indexStart = indexStart + Len(key) | |
indexEnd = InStr(indexStart, jsonAsPathsToValues, JSON_SEPARATOR_ROW) | |
If (indexEnd > 0) Then | |
result = Mid$(jsonAsPathsToValues, indexStart, indexEnd - indexStart) | |
End If | |
End If | |
End If | |
End If | |
fetchFromJsonPath = result | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment