' JSON Beautifier for BrightScript
' By BrightScripters
function json_beautify(in$) as string
indentLevel = 0
out$ = ""
newLine$ = chr(13) + chr(10)
for i = 0 to in$.len() - 1
char$ = in$.mid(i,1)
if char$ = "{" or char$ = "[" then
indentLevel = indentLevel + 1
out$ = out$ + char$ + newLine$ + indentStr(indentLevel)
else if char$ = "}" or char$ = "]" then
indentLevel = indentLevel - 1
out$ = out$ + newLine$ + indentStr(indentLevel) + char$
else if char$ = ":" then
out$ = out$ + char$ + " "
else if char$ = "," then
out$ = out$ + char$ + newLine$ + indentStr(indentLevel)
else
out$ = out$ + char$
end if
end for
return out$
end function
function indentStr( indentLevel ) as string
indentStr$ = ""
for i = 0 to indentLevel - 1
indentStr$ = indentStr$ + " "
end for
return indentStr$
end function
Comments
Join the discussionNo comments yet. Be the first to comment.
BrightScript
BrightAuthor plugin development with BrightScript, the scripting programming language for the BrightSign player.