0

From response,I have extracted the below values using JSON extractor and given name as data. But in extracted values i couldn't find double quotes for both variable name and values.

{
:   TaxcomputationId=929e1214-cc1a-e711-80c3-000d3ae017ab, 
:   EmployeeId=6524734a-c81a-e711-80c3-000d3ae017ab, 
:   PlanId=609e1214-cc1a-e711-80c3-000d3ae017ab, 
:   AmendmentIndicator=O, 
:   RPEmpId=103622, 
:   Surname=Galvin, 
:   FirstName=Benjaminn, 
:   TFN=433260373, 
:   TerminationDate=16/09/2026, 
:   HomeCountry=null, 
:   HostCountry=null, 
:   StartDateOverseasEmployment=null, 
:   EndDateOverseasEmployment=null, 
:   Assignments=
:   [
:   :   "06\/12\/2006",
:   :   "07\/10\/2010",
:   :   "United States",
:   :   "Australia"
:   ],
:    InboundAssigneeIsNotTemporaryResident=No, 
:   TaxResidencyDuringAssignment=n/a, 
:   DateOfExpiry=24/01/2025, 
:   TaxResidencyAtTP=Non-resident, 
:   ApportionedBasedOnTaxLogic=Yes, 
:   ActualPlanId=1411386-1350, 
:   DOG=/Date(1423094400000)/, 
:   DOV=/Date(1444867200000)/, 
:   DateOfGrant=05/02/2015, 
:   DateOfVest=15/10/2015, 
:   DateOfExercise=22/01/2023, 
:   DateOfSale=31/05/2021, 
:   TaxLogic=Deferred Shares/Performance Rights, 
:   TaxingPoint=Vest, 
:   TaxingDate=15/10/2015, 
:   NoOfESSInterests=52, 
:   FMVAtTPAUD=24.04, 
:   ExercisePriceAUD=0.00, 
:   NoOfSharesWithheldForHypo=1960, 
:   ApportionGrossIncome=Yes, 
:   Comments=, 
:   IncomeNetHypoAUD=-45861.80, 
:   AustralianSourcedIncome=0.00, 
:   ForeignSourcedIncome=-45861.80, 
:   ReportableAmount=0.00, 
:   PercentageOfESSIncomeTaxableInAU=0.00, 
:   IsCalculated=true, 
:   IsLocked=false, 
:   SubmissionStatus=Draft, 
:   IsError=1, 
:   ErrorCells=
:   [
:   :   30,
:   :   32
:   ]
}

From the above JSON extractor response, I need to modify the TFN value alone and need to pass this data as a parameter to next request. I have tried using beanshell coding it doesnt work. can anyone know how to change those value.

2 Answers 2

1

I would suggest discarding your JSON Path Extractor and completely switch to JSR223 PostProcessor and Groovy language. The relevant Groovy code which will:

  • Perform the extraction of first result object
  • Change "TFN" attribute value to foo
  • Store the final JSON into data JMeter Variable

will look like:

def json = new groovy.json.JsonSlurper().parse(prev.getResponseData())
def data = json.result.get(0)

data.each {entry ->
    def name = entry.getKey()
    if (name.equals("TFN")) {
        entry.setValue("foo")
    }
}
vars.put("data",new groovy.json.JsonBuilder(data).toPrettyString())

References:

Sign up to request clarification or add additional context in comments.

Comments

0

In jp@gc JSON path extractor use $TFN as JSONPATH Expression and store it in variable, then you can pass that variable as parameter in next request

2 Comments

Could you please more specific? Initially I'm using $.result[0] to extract the above values, but the double quotes is missing. From which I have to modify the TFN value as some other 9 digit value and need to pass the entire above JSON as a parameter to next request with the double quotes. Its like from result[2000] I'm extracting the result[0] alone and from which I have to update the TFN number and pass the result[0] value as paramter. i dont know how this will work in Jmeter.
Using your answer I can able to extract the TFN number, but my need is to give some other values for that TFN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.