- Question 1: Why using n++ has to be placed inside loop parse parentheses and if i put it inside for parentheses it fails to increment?
- Question 2: I'd love to hear some criticism for my implementation of this function, what could you improve?
- Note: I had to use strSplit() because it threats Delimiters parameter as expression and loop parse threats Delimiters parameter as list of separate characters.
Code: Select all
processJsonArr(JsonArr) {
resultArr := Map()
n := 1
for key, val in JsonArr {
;strip multi demensional JSON arrays, only keep first dimension
removeString := "{" . GetSubString(val, "{", "}") . "}"
val := strReplace(val,removeString, "0")
Loop Parse, val, "," {
tempArr := strSplit(A_LoopField, '":')
if (tempArr.has(1) && tempArr.has(2)) {
resultArr[n] := Map()
resultArr[n][Trim(tempArr[1], '"')] := Trim(tempArr[2], '"')
n++
}
}
}
return resultArr
}