I have about 90 fields of which only 3 are required. However, I noticed that when the data is submitted, all of the keys for the fields, including the untouched ones are included, except with null values. Is there a way to have the untouched keys be excluded from the data payload out of the box. I suppose I can call reduce and filter out the keys manually, but thought I’d check to see if there’s a way to not add these keys at all instead of adding unused keys and then manually removing them before sending. Thank you very much!
Hi @fform,
JSON Forms actually does not fill in any values by default. So if a field is not touched, there will also not be a value for it stored, including null
.
I can see two different reasons why you might encounter null values:
- Do you alrady hand in a
data
object which containsnull
values for all fields? JSON Forms will not touch these values and therefore they will also be emitted then - Did you model
default: null
in JSON Schema and use JSON Forms with AJV’suseDefault
support? In that case thenull
values will be added, however this can be prevented by just not using theuseDefault
option of AJV or removing thedefault: null
entries in your JSON Schema