I am trying to fetch values from a JsonNode
in order to carry out some validations.
However, I get null when i try to fetch the value using a predefined variable (String).
When I fetch the same value using hardcoded key, it gives me the correct value.
I tried naming a new variable String as the key, but it does not seem to be working as expected.
boolean validateFormData(JsonNode formData) {
System.out.println("1-" + formData.get("name"));
String nameVar = "name";
System.out.println("2-" + formData.get(nameVar));
return false;
}
1-"Mohammed"
2-null
Is being printed I am not sure why. The reason I want to use a variable is because the keys are not fixed, they vary from Form to Form. I am new to stackoverflow so kindly ignore the formatting errors. I shall get better with time. Any help is appreciated, thanks in advance. Even if the question is repeated kindly point me to the right answer.