How do others handle JSON manipulation?

I think the title says it all. I’m trying to write a custom exporter that will do most of what the Export Sprite Sheet tool already does, but with some additional options that I need (like automatically creating flipped versions of a sprite, exporting layers individually, etc.) and generating a JSON file with all of the important details so that we can use the sprite sheet programmatically. However, since we can’t use require, I can’t just import the json module.

Is anybody using other methods to handle JSON manipulation in Aseprite scripts? I’d rather not write an encoder to convert Lua tables to JSON, but that’s what I’m currently leaning towards.

Hi @trezy, you can use a dofile() with a third party library to read JSON files. For example, the tests repository contains an example how to do that.

Anyway there are some changes going on in the File > Export Sprite Sheet dialog for the next version (e.g. a way to split layers, tags, put different tags on each row, packaging the sprite sheet (like -sheet-pack), removing duplicates, etc.). Some of these changes are already in the Aseprite repository.

1 Like

Hey @dacap, thanks! I imported json.lua and it’s working beautifully.

I’m excited to see the updates when they come out! It sounds like they may address a lot of the issues I have. :heart: