articy:draft 3

articy:draft 3

Shibas Aug 13, 2019 @ 12:51pm
Is there a way to modify my json export?
Is there a way i can define or script the behavior how the attributes will be collected for the JSON export?

Original
{ "Type": "DefaultMainCharacterTemplate_02", "Properties": { "TechnicalName": "Ntt_909AF813", "Id": "0x100000000001A62", "Parent": "0x100000000001A5E", "Attachments": [ "0x1000000000002E7" ], "DisplayName": "Galahad", "Color": { "r": 0.3254902, "g": 0.494117647, "b": 0.09803922 },

Wanted format
{ "id":1, "battlerName":"Actor1_1", "characterIndex":0, "characterName":"Actor1", "classId":1, "equips":[1,1,2,3,0], "faceIndex":0, "faceName":"Actor1", "traits":[], "initialLevel":1, "maxLevel":99, "name":"Galahad", "nickname":"", "note":"", "profile":"" },
< >
Showing 1-2 of 2 comments
◢ k r i s ◤ Aug 13, 2019 @ 1:48pm 
It's a bit unclear what you want to accomplish because the information in both of your examples is seemingly unrelated, for the most part (only the name "Galahad" appears in both). Are you wanting to reformat the text's appearance or reformat the object field names and re-evaluate the values stored?

I'm going to assume the former just because that's easier to address.

Indenting is proper for JSON pretty-printing, but JSON is not whitespace sensitive either, fortunately. The alternative to pretty-printing is usually minification, where everything is printed to a single line to reduce file-size. I don't think there is proper vocabulary for that format you want, but essentially you want to trim the whitespace, I think. You can do this with most any scripting tools or text-editors you are familiar with (I'd use sed for this, personally), but I don't think you'll find it as a feature in AD3 ever, since it's considered improper.

Any tool for file-editing with substitution (aka find-and-replace) should be able to do this with no sweat if you know a little regex and even more reliably if your tools support POSIX. For sed with POSIX support, it would just be something simple like
sed -i 's/^[[:space:]]*//g' file.json

Is there a reason you want to re-format the JSON like this beyond just personal preference? Characteristically, JSON is designed to store and pass data, so interfacing with it is intended to be done with proper tools only which can take the data stored in JSON to be presented however you want or need after the data has been parsed. If you intend to manipulate the JSON manually, you risk making a minor error that can disrupt the JSON and make it unreadable when importing to the receiving toolset.

----------
If you wanted the latter, where the information itself is reformatted and the appearance is irrelevant, I've no context for how you decided to restructure your wanted-format, but I would use a tool like JQ to manipulate that sort of thing, personally since I tend to use BASH a lot. https://stedolan.github.io/jq/ You can find other, similar tools to suit your preference by scrolling to the bottom of this page https://json.org/ as well as just looking around Google probably.


edit
On closer inspection, I think I recognize your second example as JSON from RPG Maker MV. So was the latter your intention after all? If so, AD3 does not generate JSON that is appropriate for RMMV and you would need to write a script that parses the relevant JSON data and translates it into objects and structure that RMMV expects from its JSON. RMMV is very finnicky because of how it handles indexing within its database, so you can't simply append some generic JSON to the Actors.json file and change the name - you'll need to iterate the id too and be very mindful of the proper JSON format else the JSON becomes unreadable for simply missing a bracket or having one comma too-many. Most of the information in Actors.json is intended to be fine-tuned manually using the Database-tool within the RMMV editor itself. RMMV relies on JSON heavily, so if you have no familiarity with handling JSON or scripting, I'd recommend starting with that json.org linked above and learning the basics before even trying to apply AD3 JSON to RMMV JSON - also experimenting on backup copies of your game first, else you potentially brick your project with no recourse.

Again, I'd probably use JQ as that's what I'm personally most comfortable with - but really JSON has tools for parsing and formatting in almost every development environment so you should find whatever suits you most.
Last edited by ◢ k r i s ◤; Aug 13, 2019 @ 2:13pm
Shibas Aug 13, 2019 @ 11:28pm 
Ok i think this answer my question. I thought AD has some kind of modeling language where I can deside how the export will look like, but on second thought, if this would be a feature then you could easily export this to all other formats and not only json.

Although for the json export already an api would have to exist.
< >
Showing 1-2 of 2 comments
Per page: 1530 50