cloudflare / cloudflare/json-schema-tools

Order of properties

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
341
Forks
32
PR merge metrics
No merged PRs in 30d

Description

JavaScript does not reliably preserve object field ordering, and it is not trivial to hook `JSON.parse()` to produce a data structure that does. There are several possible solutions.

The JSON Schema UI vocabulary, if it gets off the ground, is likely to have keywords for managing display order. But there may be other options to explore. This issue tracks ideas for solving this problem.

The new implementation here tries to minimize changes to the parsed objects, so the problem may not be as bad, particularly when `allOf` is not heavily used to combine property sets.

The forthcoming UI should respect the `required` array for ordering those fields, but there is no corresponding way to order non-required fields. Also, if `allOf` and `required` are used together, the results may not be as expected.

Also paging @tajo @zackproser @Relequestual @Codelica
This replaces cloudflare/doca#28

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.