"excel vba json parser" Code Answer's
You're definitely familiar with the best coding language VBA that developers use to develop their projects and they get all their queries like "excel vba json parser" answered properly. Developers are finding an appropriate answer about excel vba json parser related to the VBA coding language. By visiting this online portal developers get answers concerning VBA codes question like excel vba json parser. Enter your desired code related query in the search bar and get every piece of information about VBA code related question on excel vba json parser.
excel vba json parser
'-----------------------------------------------------------------------------------
' VBA JSON Parser
'-----------------------------------------------------------------------------------
Option Explicit
Private p&, token, dic
Function ParseJSON(json$, Optional key$ = "obj") As Object
p = 1
token = Tokenize(json)
Set dic = CreateObject("Scripting.Dictionary")
If token(p) = "{" Then ParseObj key Else ParseArr key
Set ParseJSON = dic
End Function
Function ParseObj(key$)
Do: p = p + 1
Select Case token(p)
Case "]"
Case "[": ParseArr key
Case "{"
If token(p + 1) = "}" Then
p = p + 1
dic.Add key, "null"
Else
ParseObj key
End If
Case "}": key = ReducePath(key): Exit Do
Case ":": key = key & "." & token(p - 1)
Case ",": key = ReducePath(key)
Case Else: If token(p + 1) <> ":" Then dic.Add key, token(p)
End Select
Loop
End Function
Function ParseArr(key$)
Dim e&
Do: p = p + 1
Select Case token(p)
Case "}"
Case "{": ParseObj key & ArrayID(e)
Case "[": ParseArr key
Case "]": Exit Do
Case ":": key = key & ArrayID(e)
Case ",": e = e + 1
Case Else: dic.Add key & ArrayID(e), token(p)
End Select
Loop
End Function
'-----------------------------------------------------------------------------------
' Support Functions
'-----------------------------------------------------------------------------------
Function Tokenize(s$)
Const Pattern = """(([^""\\]|\\.)*)""|[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?|\w+|[^\s""']+?"
Tokenize = RExtract(s, Pattern, True)
End Function
Function RExtract(s$, Pattern, Optional bGroup1Bias As Boolean, Optional bGlobal As Boolean = True)
Dim c&, m, n, v
With CreateObject("vbscript.regexp")
.Global = bGlobal
.MultiLine = False
.IgnoreCase = True
.Pattern = Pattern
If .TEST(s) Then
Set m = .Execute(s)
ReDim v(1 To m.Count)
For Each n In m
c = c + 1
v(c) = n.value
If bGroup1Bias Then If Len(n.submatches(0)) Or n.value = """""" Then v(c) = n.submatches(0)
Next
End If
End With
RExtract = v
End Function
Function ArrayID$(e)
ArrayID = "(" & e & ")"
End Function
Function ReducePath$(key$)
If InStr(key, ".") Then ReducePath = Left(key, InStrRev(key, ".") - 1)
End Function
Source: academy.excelhero.com
All those coders who are working on the VBA based application and are stuck on excel vba json parser can get a collection of related answers to their query. Programmers need to enter their query on excel vba json parser related to VBA code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about excel vba json parser for the programmers working on VBA code while coding their module. Coders are also allowed to rectify already present answers of excel vba json parser while working on the VBA language code. Developers can add up suggestions if they deem fit any other answer relating to "excel vba json parser". Visit this developer's friendly online web community, CodeProZone, and get your queries like excel vba json parser resolved professionally and stay updated to the latest VBA updates.