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解析