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
dataobject which containsnullvalues for all fields? JSON Forms will not touch these values and therefore they will also be emitted then - Did you model
default: nullin JSON Schema and use JSON Forms with AJV’suseDefaultsupport? In that case thenullvalues will be added, however this can be prevented by just not using theuseDefaultoption of AJV or removing thedefault: nullentries in your JSON Schema