JSON Parser for different content

Ronan Lucio Per
Tera Contributor

Hi,

I need to create a SubFlow to parse one field from the Event table.

The fields always have a JSON string, but it comes with different content for different types of Events.

I looked at JSON Parser Action, but it expects the same JSON structure for all Events.

Is there a way to create an Action to parse JSON content that may have different keys?

1 REPLY 1

John Palmer
Tera Expert

I've got a similar issue: valid data response responds with something like:
{"data" : {"docid" :"1000123", "docname": "my document name"}}
 but if there's an error the response could be something like:
{"error" :{"errornumber": "500", "errormessage": "invalid date provided"}}
(and I may have the format wrong, but the point is that they are pretty different, and I don't know how to specify this in the JSON Parser step in an Action using the 'paste a payload example ' here....
Anybody have any ideas?
I have had success with having 2 separate JSON parser steps (consecutive, eg one right after the REST step, the next right after it:
REST Step
JSON Parse Data
JSON Parse Error
and put the expected responses for data in the one and for error in the other,  set both to  "Don't stop the action and go to the next step",and in a subsequent Script step, look for which one returned content rather than null, and do something accordingly...