Key expansion and collapsing objects
Terminology change
Change: The export parameter
no-folding
has been renamed tono-expand
, althoughno-folding
will continue to work indefinitely.
The no-folding
option has been used in Loco for many years to disable key expansion,
but this term is confusing and implies the opposite of what it does.
To clarify: A key with dot notation like "foo.bar"
is expanded (not folded) to {"foo":{"bar":...
when a nested object structure is required.
The opposite process could be called flattening or collapsing. The term "folding" is (at best) ambiguous, and has been removed from most documentation.
Export ↔ Import idempotence
Loco was exhibiting inconsistencies between expanding keys (exporting), and collapsing them (importing). This could produce duplicate assets in some edge cases, as shown below. This applied to JSON, YAML and PHP array imports, and has been fixed.
Whitespace in keys
The behaviour of key expansion is to assume white space is deliberate. Hence " foo.bar"
is exported exactly to {" foo":{"bar":...
.
However, when the importer collapsed this object, the leading space in the key was assumed a mistake and trimmed off. This would cause a new key "foo.bar"
to be added to the project.
Change: The importer now keeps whitespace in object keys. This won't fix any existing duplicates, but will prevent them in future.
Empty object keys
This refers to empty keys themselves. Not empty values assigned to keys. For example:
When importing an object structure like {"foo":{"":{"bar":"baz"}}}
the imported ID was being flattened to "foo.0.bar"
.
This is incorrect. The correct ID should be "foo..bar"
, because this is what gets expanded at export in order to produce the original object.
This erroneous key would be exported as {"foo":[{"bar":"baz"}]}
, which is not equal to what was imported.
Change: The importer no longer casts empty keys to
"0"
when collapsing objects. As above, this won't fix any existing duplicates.