Failed to build request with null values in feeder.
When the endDate value is excluded from issuersPayload Template, request builds successfully.
I want to include endDate as Null for few cases while building the payload.
Can someone assist on how to accept null values or handle them.
In JVM world, null is the value for a Map when a key is not defined. So, in the point of view of Gatling, when it tries to load the value for "endDate" attributes, it doesn’t find any, in the same state as if it weren’t present first.
As the doc suggests, please try with the jsonstringify helper:
Thanks @sbrevet for extending your help towards the problem,
It seems that the proposed solution does not solve the null issue either.
Also excluding quotes(as suggested in your response) for template field value causes a parse error saying JSON standard allows only one top-level value.
Would appreciate if you could point out if I am missing anything in my approach.
I’m sorry to hear that, we’ll dig deeper into that use case. Feel free to contribute on that subject if you find something interesting.
About the part
Which part warn you about that? I bet it is your IDE, not Gatling or your server.
The file is only a template, not a valid full JSON. Test the body for validity.
The issue comes from the fact that Gatling originally embraced the Scala mindset where null is to be avoided, while using Java libraries (Jackson maps JSON null to Java null) and now embracing Java.
I think we should be more lenient wrt null values stored in the Session.
Greetings @sbrevet ,
On the part regarding exclusion of quotes, you are right.
I do receive more of a compile time error stating “JSON standard allows only one top-level value ,
JSON standard does not allow such tokens”.
I did consult various blogs and examples besides trying separate IDEs to build a template without quotes however that did not help either.
Would be great if there is anything that can help understand the solution and kindly suggest regarding null values that cause a runtime fail which I did previously discussed.
What is your compile time error about? The file containing Gatling Expression Language is NOT a valid json (the content produced by Gatling should be a valid one)
My personal solution is to silence the IDE by explicitly set the filename extension as template-json.