]> git.proxmox.com Git - proxmox-widget-toolkit.git/commit
reader: JsonObject: cope with empty (null) return value
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 Jan 2021 15:18:04 +0000 (16:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 Jan 2021 15:21:45 +0000 (16:21 +0100)
commitfe8855e032e34747dc79f723254fc339e91f7e47
treeee4fc5c7041c7c770ebd69f10ed60749ced3d149
parentbf51bc492f1429ecfc186567e77d1c5ce64285e3
reader: JsonObject: cope with empty (null) return value

there may be cases where the backend serialization plumping code
makes it easier to return null instead of a emtpy object if a
(sub)property or whole config is not configured, as it's closer to
the truth (not configured == null, configured but empty would be {})

For objects this resulted in a exception, as the null value was tried
to be dereferenced, avoid that by defaulting to an empty object in
that case.
For arrays we already coped with that by luck, make that more
explicit to avoid future breakage.

Both result to a empty array being returned as values, which means
empty store and is deemed to be OK in that case.

The rowdef.required still applies and adds empty values though, this
could be argued to not be really fitting - for now lets keep it that
way, we could make this opt-in though if it shows that it is not
always correct.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/data/reader/JsonObject.js