JSON feeder with nested arrays; how to randomly select a record from the parent

Hello,

For my project I have a JSON feeder. I call the feeder and get a random record, so the feeder works.

However; the application that I need to check has users, and connected to these users are patients. Each user has multiple patients. For now I have a record with one user and one patient, so as you expect (and like me dislike), I have multiple records with the same user.
I have tried to nest the patients within the user record with another array, but this doesn’t seem to work.

The question is, is it possible, to randomly select a user (seems to work), and then randomly select a patient from that user record?

I have here the JSON lay out. The first one is the current situation, and the second one is my preferred situation, that doesn’t give me an answer.

CURRENT

[
	{
		"username": "UserA",
		"agendaID": AgendaA_ID,
		"patientID": PatientX_ID,
		"patientID64": "PatientX_ID64"
	},
	{
		"username": "UserA",
		"agendaID": AgendaA_ID,
		"patientID": PatientY_ID,
		"patientID64": "PatientY_ID64"
	},
	{
		"username": "UserB",
		"agendaID": AgendaB_ID,
		"patientID": PatientZ_ID,
		"patientID64": "PatientZ_ID64"
	}
]

PREFERRED

[
	{
		"username": "UserA",
		"agendaID": AgendaA_ID,
		"patients": [
			{
				"patientID": PatientX_ID,
				"patientID64": "PatientX_ID64"
			},
			{
				"patientID": PatientY_ID,
				"patientID64": "PatientY_ID64"
			},
		]
	},
	{
		"username": "UserB",
		"agendaID": AgendaB_ID,
		"patientID": PatientZ_ID,
		"patientID64": "PatientZ_ID64"
	}
]

I have tried to nest the patients within the user record with another array, but this doesn’t seem to work.

It does for sure: chore: prove that JsonFeeder supports nested objects · gatling/gatling@c0e3f65 · GitHub

is it possible, to randomly select

Have you tried the Gatling EL random() function?

Then, you can also directly use the Session API.

I have looked in you case and prepared example for it:

I make little tweaks for JSON file to be “more JSON” :slight_smile:

[
	{
		"username": "UserA",
		"agendaID": "AgendaA_ID",
		"patients": [
			{
				"patientID": "PatientAX_ID",
				"patientID64": "PatientAX_ID64"
			},
			{
				"patientID": "PatientAY_ID",
				"patientID64": "PatientAY_ID64"
			}
		]
	},
	{
		"username": "UserB",
		"agendaID": "AgendaB_ID",
		"patients": [
			{
				"patientID": "PatientBX_ID",
				"patientID64": "PatientBX_ID64"
			},
			{
				"patientID": "PatientBY_ID",
				"patientID64": "PatientBY_ID64"
			}
		]
	}
]

WDYT ? :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.