2017-04-10 129 views
0

提取使用JSON路径抽出值我需要从下面的响应中提取的第一组值,双引号丢失,而在JMeter的

{ 
: "result": 
: [ 
: : { 
: : : "TaxcomputationId":"08f6ad40-cc1a-e711-80c3-000d3ae017ab", 
: : : "EmployeeId":"eb8455e9-c71a-e711-80c3-000d3ae017ab", 
: : : "PlanId":"d6f5ad40-cc1a-e711-80c3-000d3ae017ab", 
: : : "AmendmentIndicator":"O", 
: : : "RPEmpId":"103622", 
: : : "Surname":"Galvin", 
: : : "FirstName":"Benjamin", 
: : : "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":"", 
: : : "TaxResidencyDuringAssignment":"", 
: : : "DateOfExpiry":"24/01/2025", 
: : : "TaxResidencyAtTP":"", 
: : : "ApportionedBasedOnTaxLogic":"n/a", 
: : : "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":"", 
: : : "ExercisePriceAUD":"", 
: : : "NoOfSharesWithheldForHypo":null, 
: : : "ApportionGrossIncome":"Yes", 
: : : "Comments":null, 
: : : "IncomeNetHypoAUD":"", 
: : : "AustralianSourcedIncome":"", 
: : : "ForeignSourcedIncome":"", 
: : : "ReportableAmount":"", 
: : : "PercentageOfESSIncomeTaxableInAU":"", 
: : : "IsCalculated":false, 
: : : "IsLocked":false, 
: : : "SubmissionStatus":"Draft", 
: : : "IsError":1, 
: : : "ErrorCells": 
: : : [ 
: : : : 23 
: : : ] 
: : }, 
: : { 
: : : "TaxcomputationId":"09f6ad40-cc1a-e711-80c3-000d3ae017ab", 
: : : "EmployeeId":"ec8455e9-c71a-e711-80c3-000d3ae017ab", 
: : : "PlanId":"d7f5ad40-cc1a-e711-80c3-000d3ae017ab", 
: : : "AmendmentIndicator":"O", 
: : : "RPEmpId":"103623", 
: : : "Surname":"Galvin", 
: : : "FirstName":"Benjamin", 
: : : "TFN":"433260374", 
: : : "TerminationDate":"17/09/2026", 
: : : "HomeCountry":null, 
: : : "HostCountry":null, 
: : : "StartDateOverseasEmployment":null, 
: : : "EndDateOverseasEmployment":null, 
: : : "Assignments": 
: : : [ 
: : : : "04/03/2009", 
: : : : "08/03/2013", 
: : : : "United States", 
: : : : "Kuwait" 
: : : ], 
: : : "InboundAssigneeIsNotTemporaryResident":"", 
: : : "TaxResidencyDuringAssignment":"", 
: : : "DateOfExpiry":"25/01/2025", 
: : : "TaxResidencyAtTP":"", 
: : : "ApportionedBasedOnTaxLogic":"n/a", 
: : : "ActualPlanId":"1411386-1351", 
: : : "DOG":"\/Date(1431388800000)\/", 
: : : "DOV":"\/Date(1447545600000)\/", 
: : : "DateOfGrant":"12/05/2015", 
: : : "DateOfVest":"15/11/2015", 
: : : "DateOfExercise":"23/01/2023", 
: : : "DateOfSale":"01/06/2021", 
: : : "TaxLogic":"Deferred Shares/Performance Rights", 
: : : "TaxingPoint":"Vest", 
: : : "TaxingDate":"15/11/2015", 
: : : "NoOfESSInterests":31, 
: : : "FMVAtTPAUD":"", 
: : : "ExercisePriceAUD":"", 
: : : "NoOfSharesWithheldForHypo":null, 
: : : "ApportionGrossIncome":"Yes", 
: : : "Comments":null, 
: : : "IncomeNetHypoAUD":"", 
: : : "AustralianSourcedIncome":"", 
: : : "ForeignSourcedIncome":"", 
: : : "ReportableAmount":"", 
: : : "PercentageOfESSIncomeTaxableInAU":"", 
: : : "IsCalculated":false, 
: : : "IsLocked":false, 
: : : "SubmissionStatus":"Draft", 
: : : "IsError":1, 
: : : "ErrorCells": 
: : : [ 
: : : : 23 
: : : ] 
: : } 
: ] 
} 

我已经使用JSON路径抽出与$.result[0]。使用此代码,我能提取第一组值,但如下返回响应,

{ 
: 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 
: ] 
} 

你可以找到的是双引号缺失。但我需要用双引号提取。任何人都可以为我提供解决方案。

回答

0

听起来就像在JSON路径抽出插件的错误,我建议通过JMeter Plugins support forum

同时报告它有以下解决方法:

  1. 使用JSON Extractor因为JMeter的3.0
  2. 可用如果您不能升级到JMeter 3.0,则可以使用JSR223 PostProcessor,Groovy language和以下代码:

    def json = new groovy.json.JsonSlurper().parse(prev.getResponseData()) 
    def firstResult = new groovy.json.JsonBuilder(json.result.get(0)).toPrettyString() 
    vars.put("result", firstResult); 
    
+0

谢谢你德米特里。它的工作 – Renu