Feature request: Could framing return properties in the order listed by the frame? · Issue #542 · json-ld/json-ld.org (original) (raw)
Currently it appears that properties are sorted into alphabetical order after any JSON-LD operation (compaction, framing).
In the context of framing, this is sometimes a nice feature, since it means that after framing multiple input JSON files, the JSON data is at least in a consistent order.
I understand that ordering is semantically meaningless, but as framing exists to turn the graph (which could correspond to multiple different trees) into a predictable JSON tree as a convenience for developers, it seems natural to me that if an explicit ordering is given in the frame, that the algorithm would respect that order rather than alphabetize. For example, if my data is:
{
"@context": "http://schema.org/",
"@id": "document",
"b": "text",
"a": "more text"
}
Under the frame:
{
"@context": "http://schema.org/",
"@id": "document",
"b": {},
"a": {}
}
the returned document reverses the order of b
and a
(to be alphabetical), and not the order given in the frame. Framing is a really elegant way to specify the nesting order, but it would be nice for framing to also be able to dictate the ordering, so that the output data file really follows the exact structure of the given frame.
Related issue: there is no way to indicate that referenced nodes should occur before they are references (excluding circular references), which can be useful in streaming files. Having control of the node order via the frame would also give a mechanism to address that.
Hope this makes sense and apologies if I'm missing something fundamental here that makes alphabetizing the node order the only logical thing to do; or if I've misunderstood the expected behavior.