Parse 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, throwIfError() )
안전한 JSON 구문 분석