Ask a Question

Put a Json in a variable ?

SOLVED
Anabelle
Occasional Contributor

Put a Json in a variable ?

Hi all,

In my keywordTest, I send au request with a json body.

 

I would like stock this json in a variable because I need to work with it ( retrieve data & modify je the json )

Anabelle_0-1691414691614.png

 

Is it possible ?

 

Thank you so much for helping

3 REPLIES 3
rraghvani
Champion Level 3

Here's an example,

rraghvani_0-1691416174706.png

using JSON to construct the string and to parse

Anabelle
Occasional Contributor

Hello, thanks for your helping.

 

How I can modify a value in my json ?

 

I need to increment 'numeroPrestation' in my json each time the test has to run

 

I try to retrieve it and put in a variable but I can't put this variable in my json

 

Thanks in advance !

 

Ana

rraghvani
Champion Level 3

In the example I have shown, I have an object declared as 

 

myjson = {
  title: "SmartBear",
  body: "TestComplete",
  userid: 1
}

 

I can modify the value like so,

 

myjson.body = "TestExecute"

 

and then convert to json, as shown in the example.

 

You have to create an object, in order to modify the values. There's plenty of examples on the internet.

cancel
Showing results for 
Search instead for 
Did you mean: