JSON 구문 분석 ()는 오류를 잘 처리하지 못하기 때문에 사용하기 어렵습니다. RunProgram 또는 버튼의 콜백에서 실패를 알리는 원치 않는 모델 대화 상자를 생성합니다. 또한 로그에서 실패를 알립니다. 이 문제를 해결하려면 추가 JSL이 필요합니다.
New Window( "parsejson",
Button Box( "parse",
local( {birestore, errText},
birestore = Batch Interactive( 1 ); // makes an alert dialog from a button without this
errText = Log Capture( p = Parse JSON( "\!n" /* invalid json error */ ) ); // writes to the log without this
Batch Interactive( birestore ); // pop the previous behavior
If( Length( errText ), Throw( "Caught an error:" || char(errText) ) ); // handle unexpected error, somehow
/* use p here */
)
)
);
제안: parseJson(x, throwIf 오류() )
비상 안전 JSON 구문 분석