Skip to content

Commit

Permalink
Optimize key parsing to avoid concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdmk committed Oct 3, 2022
1 parent fc136da commit 80eea30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jsonObject.class.asp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class JSONobject
' Parse a JSON string and populate the object
public function parse(byval strJson)
dim regex, i, size, char, prevchar, quoted
dim mode, item, key, value, openArray, openObject
dim mode, item, key, keyStart, value, openArray, openObject
dim actualLCID, tmpArray, tmpObj, addedToArray
dim root, currentObject, currentArray
Expand Down Expand Up @@ -227,6 +227,7 @@ class JSONobject
key = ""
if char = """" then
log("Open key")
keyStart = i + 1
mode = "closeKey"
elseif char = "}" then ' empty objects
log("Empty object")
Expand All @@ -238,10 +239,9 @@ class JSONobject
elseif mode = "closeKey" then
' If it finds a non scaped quotation, change to value mode
if char = """" and prevchar <> "\" then
key = mid(strJson, keyStart, i - keyStart)
log("Close key: """ & key & """")
mode = "preValue"
else
key = key & char
end if
' Wait until a colon char (:) to begin the value
Expand Down

0 comments on commit 80eea30

Please sign in to comment.