Improvement: Make array format configurable and/or default to table format
See original GitHub issueGeneral information
- json-editor version: 2.4.0
I am aiming to use JSON Editor without needing to include properties related to formatting within the JSON Schema instance (for my use case the instance needs to contain only data, not information about how to display that data), but in order to get array input to display in JSON Editor, it must have the key/value pair "format": "table"
included in the instance.
Actual behavior
When you leave it out, you get this (note the missing input field, row label and button):
Expected behavior
But when you add the "format": "table"
key/value pair it displays correctly:
Steps to reproduce the behavior
You can try this yourself by going to the interactive editor:
https://json-editor.github.io/json-editor/
Then scroll down to replace the default schema instance with the instance below, then click Update Schema. Reload the page and try it with and without the format
key/value pair included.
{
"type": "object",
"title": "Test of Array without Format key",
"properties": {
"linked_schemas": {
"title": "Linked Schemas",
"description": "The schemaIds against which the profile must be validated",
"type": "array",
"format": "table",
"items": {
"type": "string",
"pattern": "[A-Fa-f0-9]{64}"
},
"minItems": 1,
"maxItems": 10,
"uniqueItems": true
}
}
}
Possible solutions
There are two possible solutions I can think of to fix/improve this:
- Automatically assume
format
istable
for an array as a default if noformat
property is specified. - Add an
array_layout
configuration option, as is currently available for objects withobject_layout
(as noted in the README).
I took a look at the code and could not figure out where format: table
for arrays was recognized and then processed, but if you can point me in the right direction, I would be glad to try to implement one of the above two solutions and create a PR, presuming you are happy to make this type of a change. I do think offering an option to remove a formatting property within a schema instance is a worthwhile improvement.
Thanks in advance for considering this suggestion.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Pr wellcome! 😃 Then we can do a review
Tried it and the issue is indeed resolved. Thank you!