cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

JMP Wish List

We want to hear your ideas for improving JMP. Share them here.
Choose Language Hide Translation Bar
0 Kudos

Parse JSON error handling

Parse JSON() is hard to use because it does not handle errors nicely. In a callback, perhaps from RunProgram or a button, it will create an unwanted model dialog announcing the failure. It will also announce the failure in the log. It takes extra JSL to fix it up:

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 */
        )
    )
);

Suggestion: add an optional parameter to change the behavior, something like parseJson(x, throwIfError() )

Failsafe JSON parsing