cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Due to the recently reported Microsoft outage, users may be temporarily unable to access My JMP or experience a delay receiving their verification codes. If you have previously installed JMP on your computer, this outage should not impact your ability to access the software. My JMP services will be restored as soon as Microsoft resolves this issue.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

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