Skip to content

Override isCollection for custom objects #203

Closed
@markdascher

Description

@markdascher

Suggestion
Provide some way to use custom objects without treating them all as collections. There's a showCollectionWrapper property which sounds close, except it just hides the braces. It doesn't get rid of the extra line break, expand/contract functionality, etc. Maybe something like isCollection: false in customNodeDefinitions.

In our case, only "plain" Objects are collections, since we're parsing JSON (override some specific nodes with a custom object) and then passing in the result. So some logic like value.constructor === Object might also work. That probably wouldn't work in general, though.

Use case
We'd like to parse JSON using the lossless-json library, which puts numbers into a LosslessNumber type. The purpose is to show formatted JSON that doesn't modify the input at all. It doesn't translate 1.0000 into 1 or translate 123456789012345678901234567890 into 1.2345678901234568e+29, etc.

We can almost make this work with json-edit-react already, but it treats LosslessNumber as a collection.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions