Hey there!
So I have a custom extension I’m working on that allows the user to add some extra data into selected tags (specifically a pivot, with an x and y value).
I’m using Extension-defined properties to insert the data into the respective tag:
tag.properties(PLUGIN_KEY).pivot = {x = x, y = y}
That said, it looks like the native json exporter won’t export any of these extension or user defined properties in the json file.
Is there a plan to include this in future releases?
If not, any guidance on how I can inject data into the export via a new command group? Is that even possible?
At the very worst case, I can push this data into the user data field which I know is indeed exported into the json file, but I’d prefer not to do that.
Thank you so much!
Thank you @Gasparoken .
I’ve gone ahead and created pull request and linked the issue you created:
main
← Vampire-Twin-Studios:feat/export-user-plugin-data
opened 07:48AM - 01 Jun 25 UTC
I agree that my contributions are licensed under the Individual Contributor Lice… nse Agreement V4.0 ("CLA") as stated in https://github.com/igarastudio/cla/blob/main/cla.md
I have signed the CLA following the steps given in https://github.com/igarastudio/cla#signing
-----------------------------------------------------
### Related Ticket(s):
[Include User-defined & Extension-defined Properties in Exported JSON #5186](https://github.com/aseprite/aseprite/issues/5186)
### Context:
Since [Aseprite 1.3-rc1](https://aseprite.org/api/properties#properties) you can have user-defined and extension-defined properties for each of these objects.
However, these properties are currently not exported into the JSON file.
This would be a very handy feature so that plugins can fully take advantage of these custom properties when parsing aseprite json files in other tools (Unity, etc...).
### Solution:
- **Full serialization of custom properties for Tags, Layers, Cels, and Slices:**
The exported JSON now includes all user-defined and extension-defined properties for these objects, under a `"properties"` key. This ensures that any metadata added by users or extensions is preserved and accessible in downstream tools.
- **Generic, type-safe serialization helper:**
Introduced a reusable, type-constrained helper function (`serialize_userdata_properties`) that serializes the properties of any object derived from `WithUserData`. This ensures consistent and safe handling of properties across all supported object types.
- **Accurate variant type handling:**
The serialization logic for property values now robustly supports all integer types and other supported types in `UserData::Variant`, guaranteeing correct JSON output for all property values, regardless of how they are stored or loaded.
- **Consistent structure for plugin and extension data:**
The JSON output structure is now consistent for all objects, making it easier for plugins and external tools (such as Unity importers) to reliably access custom metadata.
### Testing
#### Compilation:
- [x] Control compilation at base `master` (SHA `66123e9d5739fdf870336fd4eda91e0054421ea0`)
- [x] Compilation at tip of this feature branch (SHA `42e386b701064b9e8a4de9409ec7cbf39f40a7e4`)
#### Functional Test Cases:
- [x] Frame Tags
- [x] Layer
- [x] Cel
In each case, a similar lua snippet was run to add a user and group/extension property to each of the above objects.
```
function injectPropertiesFor(targetType)
local target = app[targetType]
if not target then
app.alert("No active " .. targetType .. ".")
return
end
target.properties = {}
target.properties.user_defined_data = targetType .. " user defined data"
local props = target.properties("my-plugin")
if not props then
target.properties("my-plugin", {})
props = target.properties("my-plugin")
end
props.extension_defined_data = targetType .. " extension defined data"
app.alert("Injected " .. targetType .. " properties.")
end
```
JSON Result:
[meta_export.json](https://github.com/user-attachments/files/20538803/meta_export.json)
Thank you