PlayFramework exclude null when converting Json to DynamicForm

I am posting a simple json document below to a Play Framework app. Below the json document only contains key / values โ€‹โ€‹that have been changed / updated by the user.

{ "id": "abc", "first_name": "Mark", "last_name": null, "city": "NY" }

      

I then use Map<String, String> mapParameters = Form.forms().bindFromRequest().data

to get the json document data as a map of key / value pairs to update my custom document.

However, the converted Map<String, String>

is NOT , contains the key entry for "last_name", which is null.

So I don't have a clear way to distinguish the above json document from the following json document which did NOT intentionally include the last_name key / value because "last_name" has not been changed / updated by the user.

{ "id": "abc", "first_name": "Matt", "city": "NJ" }

      

Is there a reason why PlayFramework is ignoring key / value together if the value is null? and is there any other way to get the transformed Map<String, String>

that will include all keys in the json document even if the value is null?

I hope my question is clear and just for the sake of being clear, the first json document above is to remove the last name, and the second json document is to keep the existing last_name as it is.

Thanks in advance.

+3


source to share





All Articles