| None. |
|
Returns the one-based source column of the last JSON failure, or 0 when unavailable. The finishing touch on a good parse error: combined with JsonErrorLine it gives an exact line-and-column position where ParseJson or LoadJson stopped, so an error message can draw a caret right under the offending character of a broken settings file - String(" ",JsonErrorColumn()-1)+"^" does the trick. Columns count from 1 at the start of the line. It is one of five companions set together on failure - JsonError has the message, JsonErrorOffset the byte offset, JsonErrorPath the logical path. Failures without a meaningful position return 0. A successful parse or load clears the family, so read it straight after the failed call. The value is context-local to the main program or the Job worker that failed. For the full rules, see the Application Data language reference. See also: JsonError, JsonErrorLine, JsonErrorOffset, JsonErrorPath, ParseJson. |
; JsonErrorColumn Example
; -----------------------
q$=Chr(34) ; Double-quote character, for building JSON text
; A save-game file that was corrupted on line 3
line1$="{"
line2$=q+"player"+q+": "+q+"Aria"+q+","
line3$=q+"gold"+q+": 12x5"
line4$="}"
src$=line1+Chr(10)+line2+Chr(10)+line3+Chr(10)+line4
Print "Parsing this broken save-game:"
Print line1
Print line2
Print line3
Print line4
Print ""
save=ParseJson(src)
Print "ParseJson returned "+save+" (0 = failed): "+JsonError()
Print ""
; JsonErrorColumn returns the one-based column on the error line
col=JsonErrorColumn()
Print "JsonErrorColumn: "+col+" (on line "+JsonErrorLine()+")"
; Use it to draw a marker under the offending character
Print ""
Print line3
Print String(" ",col-1)+"^ here"
Print ""
Print "Press any key to close the example"
WaitKey
End