Skip to main content
Nintex Community Menu Bar
Solved

Regex json to filter out value

  • December 13, 2022
  • 8 replies
  • 721 views

Forum|alt.badge.img+4

I’ve got the following json response:
{"access_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IkExRUQxNDU5MDM3QUMxOEVDRDIwQjMxNjAzRDQwRUE0NjU3MTU3N0JSUzI1NiIsInR5cCI6ImF0K2p3dCIsIng1dCI6Im9lMFVXUU42d1k3TklMTVdBOVFPcEdWeFYzcyJ9.eyJuYmYiOjE2Nz","expires_in":86400,"token_type":"Bearer","scope":"test-scope"}

 

In Nintex workflow I want to filter out the value of the ‘access_token’ key. Can someone provide me the regex for this? 

Best answer by Garrett

Hi @Bob_S 

 

This is using Workflow O365 but I believe it should work for you.

String: <Your source JSON>

REPLACE Operation

Pattern: ({"access_token":")(.*)(","ex)(.*})

Replacement String: $2

Output: <Your output variable>

 

Result Output (using Log to History)

 

Hope that helps

8 replies

Garrett
Forum|alt.badge.img+16
  • Scout
  • Answer
  • December 13, 2022

Hi @Bob_S 

 

This is using Workflow O365 but I believe it should work for you.

String: <Your source JSON>

REPLACE Operation

Pattern: ({"access_token":")(.*)(","ex)(.*})

Replacement String: $2

Output: <Your output variable>

 

Result Output (using Log to History)

 

Hope that helps


Forum|alt.badge.img+2
  • Rookie
  • September 11, 2023

Hi Bob, have you found a solution for this? I also just got the same task of extracting an access_token from json on Nintex for SharePoint on prem.


Forum|alt.badge.img+4
  • Author
  • Scholar
  • September 12, 2023

Yeah my problem got solved. Are you facing the exact same issue? Or do you need to extract from a different json?


Forum|alt.badge.img+2
  • Rookie
  • September 12, 2023

My json is in a different order but the content is (nearly) the same.


Forum|alt.badge.img+4
  • Author
  • Scholar
  • September 12, 2023

Look at the solution given above, that worked for me! Or send an example of your json so I can take a look at it.


Forum|alt.badge.img+2
  • Rookie
  • September 12, 2023

My json looks like this (access_token shortened for readability):

{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"I6Il9BM2d5bE.eyJhdMMjLTW0_QDjv-7eTK0-uC3hb-JcCMBCag"}


Forum|alt.badge.img+4
  • Author
  • Scholar
  • September 12, 2023

Can you put in this:


Pattern: ({*.)(.*)("access_token":")(.*)(.*"})

Replacement string: $4 


Forum|alt.badge.img+2
  • Rookie
  • September 12, 2023
Thank you, Bob. This works for me.