| None. |
|
Returns the one-based source line of the last JSON failure, or 0 when unavailable. When a hand-edited settings file or a modded save refuses to parse, telling the player "line 3" beats telling them "somewhere". JsonErrorLine reports where ParseJson or LoadJson gave up, counting lines from 1 like any text editor - ideal for pointing an in-game editor or an error dialog straight at the problem. It is one of five companions set together on failure: JsonError has the message, JsonErrorColumn the column on this line, JsonErrorOffset the byte offset, and JsonErrorPath the logical path. Some failures have no meaningful position (for example a size limit hit before parsing) - then JsonErrorLine returns 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, JsonErrorColumn, JsonErrorOffset, JsonErrorPath, ParseJson. |
; JsonErrorLine Example
; ---------------------
q$=Chr(34) ; Double-quote character, for building JSON text
; A save-game file that was corrupted: the error is 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 "1: "+line1
Print "2: "+line2
Print "3: "+line3
Print "4: "+line4
Print ""
save=ParseJson(src)
Print "ParseJson returned "+save+" (0 = failed): "+JsonError()
Print ""
; JsonErrorLine returns the one-based source line of the error -
; perfect for pointing an editor straight at the problem
Print "JsonErrorLine: "+JsonErrorLine()
Print ""
Print "Press any key to close the example"
WaitKey
End