I am sending json files as body. There are like 10k json files so I am using Directory Listing Config in jmeter plugin. While reading the json file I am using this:
${__FileToString(${file},,)}
to read file information. Json file looks like this:
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:oaeignaeogin",
"resource": {
"resourceType": "Player",
"id": "aegaegaeg-aega-aegg-aegeag-aegaegeag",
"text": {
"status": "generated",
"div": "<div xmlns=\"stuff"
},
"extension": [
{
"url": "http://something.org/something/StructureDefinition/player-mothersMaidenName",
"valueString": "Smith2 Pet4"
},
{
"url": "http://something.org/something/StructureDefinition/player-birthPlace",
"valueAddress": {
"city": "Boston"
}
},
{
"url": "http://something.some.io/some/dinasour-adjusted-wife-yeast",
"valueDecimal": 0.0
},
{
"url": "http://something.some.io/some/dinasour-adjusted-wife-yeast",
"valueDecimal": 36.0
}
],
"identifier": [
{
"system": "https://getsome.com/saliva/slurp",
"value": "wagwag-awg-awg-wagawg-awgawgawg"
},
{
"type": {
"coding": [
{
"system": "http://terminology.something.org/CodeSystem/v75",
"code": "GA",
"display": "Grammer is best"
}
],
"text": "Medicine Record Number"
},
"system": "http://hahaha.smart.org",
"value": "affa-afaf-afaf-af-asf"
},
{
"type": {
"coding": [
{
"system": "http://terminology.highlife.org/CodeSystem/v25",
"code": "SS",
"display": "Number"
}
],
"text": "Social"
},
"system": "http://highlife.org/farts/sam/us-ssm",
"value": "333-33-0000"
},
{
"type": {
"coding": [
{
"system": "http://highlife.org/farts/sam/us-ssm",
"code": "DL",
"display": "Driver's License"
}
],
"text": "Driver's License"
},
"system": "urn:age:aeg:eagag:ageag",
"value": "B35353"
},
{
"type": {
"coding": [
{
"system": "http://highlife.org/farts/sam/us-ssm",
"code": "PN",
"display": "Number"
}
],
"text": "Number"
},
"system": "http://records.org/farts/sand/number",
"value": "M0359035R"
}
],
"name": [
{
"use": "official",
"family": "Haldi3535",
"given": [
"Bana0935"
],
"prefix": [
"Mr."
]
}
],
"telecom": [
{
"system": "phone",
"value": "000-000-0000",
"use": "home"
}
],
"gender": "male",
"birthDate": "9352-09-06",
"address": [
{
"extension": [
{
"url": "http://highlife.org/farts/sam/us-ssm",
"extension": [
{
"url": "latitude",
"valueDecimal": 42.074504688657385
},
{
"url": "longitude",
"valueDecimal": -71.02247449124029
}
]
}
],
"line": [
"3535 Willi"
],
"city": "Brockton",
"state": "Massachusetts"
}
],
"maritalStatus": {
"coding": [
{
"system": "http://highlife.org/farts/sam/us-ssm",
"code": "S",
"display": "S"
}
],
"text": "S"
},
"multipleBirthBoolean": false,
"communication": [
{
"language": {
"coding": [
{
"system": "urn:437",
"code": "en-US",
"display": "English"
}
],
"text": "English"
}
}
]
},
"request": {
"method": "POST",
"url": "Patient"
}
}
]
}
What do I do so that I only read entries upto 25 entries and then send it as body? Any help is appreciated.
CodePudding user response:
Your JSON file contains only one entry
element
If there are files with more than one entry
and you need to send only first 25 you will need to parse the JSON using JSR223 PreProcessor, extract first 25 entries, re-build the JSON and overwrite the variable.
Add JSR223 PreProcessor as a child of the request which you need to send
Put the following code into "Script" area:
def json = new groovy.json.JsonSlurper().parse(new File(vars.get('file'))) if (json.entry.size() > 25) { json.entry = json.entry.take(25) } vars.put('payload', new groovy.json.JsonBuilder(json).toPrettyString())
Replace
${__FileToString(${file},,)}
in the "Body Data" tab of the "HTTP Request" Sampler
More information: