I am using Blueprism to make an API Call. The response is a block of json. I need to extract the conversation id from:
{"results":[{"group":{"queueId":"aad701ad-56db-452e-8b70-aa9abd6046c7","mediaType":"email"},"data":[{"metric":"oWaiting","stats":{"count":1},"truncated":false,"observations":[{"observationDate":"2022-01-20T11:19:04.882Z","conversationId":"116b9f91-bf82-4275-9cdc-c405068b4cba","sessionId":"f97de11e-eb99-4781-ae13-33a9e5b6c3f0","routingPriority":0,"direction":"inbound","addressFrom":"[email protected]","addressTo":"[email protected]","requestedRoutings":["Standard"]}]}]}]}
I am using:
^.*? with conversationId ([a-f0-9] )
CodePudding user response:
.*conversationId":"([^"] )".*
will save the conversationId into capture group 1.
If you are using perl, you could do this:
s/.*conversationId":"([^"] )".*/\1/
this works for your example but it's probably not going to scale well to different input JSON messages.
CodePudding user response:
Ultimately I was going about this the wrong way. I should have been parsing the json and not trying to extract a particular string.
Blueprism has a json object which completes this very function. https://digitalexchange.blueprism.com/dx/entry/3439/solution/utility---json
