Map type


Is it possible to implement a “map” control, ie. an object where the keys are unknown, but the values are of a specific type? With Json schema it would look like this, for a map with integer values:

“type”: “object”,
“additionalProperties”: {“type”: “integer”}

I see it working a lot like an array control, where there is a button to create a new entry.
For each entry there would then be a “string control”, to set the object key, and from 1 to many controls to handle the object value(s).

[original thread by Jens Ahlsten Herlevsen]

Hi! Yes that is definitely possible. When you implement a custom renderer you have full control over everything it renders, therefore you can also support additionalProperties semantics as you outlined.

What exactly is the best approach depends on your requirements. For example you could implement a custom renderer for type: "object with a defined additionalProperties. In it you delegate to the already existing object renderer for all of the “normal” properties while adding the array-like functionality for the additionalProperties yourself.

So in general I don’t see any problem to implement this. The amount of reuse you get out of the existing JSON Forms renderers depends on your exact requirements.

[Jens Ahlsten Herlevsen]

Thans @sdirix. I managed to get it working :slight_smile: