json-forms icon indicating copy to clipboard operation
json-forms copied to clipboard

Nulls are returned instead of empty strings

Open ghost opened this issue 5 years ago • 1 comments

When new sting elements are added and they are not filled with any data, nulls are returned instead. However it should be empty strings according to the schema.

See the screenshot:

Screen Shot 2019-08-14 at 2 50 09 PM

ghost avatar Aug 14 '19 18:08 ghost

function processOptions(parentId, names, data, cb) { var schemas = {}; var schema = { type: "string" };

if (data[parentId] === "efg") { schema.title = "efg"; schema.enum = ["", ""]; } else if (data[parentId] === "abc") { schema.title = "abc"; schema.enum = ["", ""]; }

// Check for null values and convert them to empty strings var subOptionValue = data[parentId + ".suboption1"]; if (subOptionValue === null) { subOptionValue = ""; }

schemas["$.sub" + parentId] = schema; schemas["$.sub" + parentId].default = subOptionValue; setTimeout(function() { cb(schemas); }, 500); // in order to show asynchrony }

peeyush12345 avatar Jun 25 '23 17:06 peeyush12345