Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Text functions not working on JSON Object or variable

Steve Kohrs September 1, 2023

I'm trying to parse a Web Response which is a JSON object.  I saw several suggestions to use text functions to extract substrings from the response.  However, it doesn't appear to work as described.  The output is just blank.  I've also tried creating a variable to force it to text, but the output is still blank.

tempWebResponse = {{webResponse.body.results}}
UserId = {{#debug}}{{tempWebReponse.substring(8, 15)}}{{/}}

 

 

Audit Log:

Action details:
["10099"]

Send web request
Successfully published web request

Log action
Log
tempWebResponse: {users={1220280={id=1220280, first_name=Steve,...}

Create variable
Debug message

Log action
Log
UserID:

2 answers

1 accepted

1 vote
Answer accepted
Steve Kohrs September 5, 2023

I think I just had a typo above.  Today, I'm able to use the text functions to extract substrings from the JSON object.

Jehan Bhathena
Community Champion
September 6, 2023

Glad to know it works now. :-)

Perhaps you can share the solution here, and mark this thread as the Accepted answer, it might help another member from the community reach the solution quicker.

Steve Kohrs September 7, 2023

Here's the working example:

Create variable:
usersWebResponse = {{webResponse.body.results.users}}

Create variable:
userId = {{usersWebResponse.substringBetween("{","=")}}

 

0 votes
Jehan Bhathena
Community Champion
September 3, 2023

Hi @Steve Kohrs ,

Assuming this is your webresponse :

{users={1220280={id=1220280, first_name=Steve,...}

You should be able to access the users id using this:

{{webResponse.body.1220280.id}}
Steve Kohrs September 5, 2023

The object name, 1220280, is a dynamic value.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events