AnsweredAssumed Answered

Can you parse JSON responses?

Question asked by MollyKFoley on Apr 24, 2018
Latest reply on Apr 24, 2018 by MollyKFoley

I have a geoprocessing service with a bunch of custom errors built in. If an error occurs, I would like to get the error message and return it to the user, but the results of a geoprocessing service are these huge JSON responses. Is there a way to easily parse these? 

 

For instance, this is the ESRI job failure response, all I want is the line in red below to return the user:

esriJobFailed(j62e4482338eb4149a0f8e9a6e574cd90):{"messages":[{"type":"esriJobMessageTypeInformative","description":"Submitted."},{"type":"esriJobMessageTypeInformative","description":"Executing..."},{"type":"esriJobMessageTypeInformative","description":"Executing (HabitatClassification): HabitatClassification C:\\arcgisserver\\directories\\arcgissystem\\arcgisuploads\\services\\MollyGPTesting\\HabitatClassification.GPServer\\ie6130b0b-b340-47e6-8b46-dcf2926abbe2\\VA_Habitat.gdb.zip AL"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Tue Apr 24 14:44:29 2018"},{"type":"esriJobMessageTypeInformative","description":"Executing (HabitatClassification): HabitatClassification C:\\arcgisserver\\directories\\arcgissystem\\arcgisuploads\\services\\MollyGPTesting\\HabitatClassification.GPServer\\ie6130b0b-b340-47e6-8b46-dcf2926abbe2\\VA_Habitat.gdb.zip AL"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Tue Apr 24 14:44:29 2018"},{"type":"esriJobMessageTypeInformative","description":"Running script HabitatClassification..."},{"type":"esriJobMessageTypeInformative","description":"Executing script \"HabitatClassification\"..."},{"type":"esriJobMessageTypeInformative","description":"Start Time 04/24/2018 14:44.29..."},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch\\scratch.gdb"},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch"},{"type":"esriJobMessageTypeInformative","description":"Successfully extracted zip file..."},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch\\VA_Habitat.gdb"},{"type":"esriJobMessageTypeError","description":"You have renamed a field from the original template. Please return it to its original state."},

Outcomes