question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improvement: Make array format configurable and/or default to table format

See original GitHub issue

General 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):

image

Expected behavior

But when you add the "format": "table" key/value pair it displays correctly:

image

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:

  1. Automatically assume format is table for an array as a default if no format property is specified.
  2. Add an array_layout configuration option, as is currently available for objects with object_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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
germanbisurgicommented, Oct 17, 2020

Pr wellcome! 😃 Then we can do a review

0reactions
geoffturkcommented, Oct 20, 2020

Tried it and the issue is indeed resolved. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pretty print an array to a table - javascript - Stack Overflow
I know there is method console.table but I can't use it in my case, is there any way to format it using just...
Read more >
Work with arrays | BigQuery - Google Cloud
With Google Standard SQL, you can construct array literals, build arrays from subqueries using the ARRAY function, and aggregate values into an array...
Read more >
Clear format of an array, insert clear info into excel table
Solved: I am using "SharePoint-List Folder" to list files in several folders, and I insert those data(file name and last modified time)
Read more >
7. Execute & Format Control - Mastering Dyalog APL
Monadic format converts any array, whatever its value, into its character representation. This applies to numbers, characters, and nested arrays.
Read more >
rubocop/default.yml at master - GitHub
Default formatter will be used if no `-f/--format` option is given. ... All cops except the ones configured `Enabled: false` in this file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found