• Editor
  • Command line tool: convert / import json -> export binary

Hi,

Is there a command line tool to convert json to binary format?

We use Spine to create animations and export the skeleton data. After that we do some customizations on the json file.
However, we need the end product to be a binary format.

Import -> Export by hand is tedious and slow.

A command line tool (parameters passed to spine) seems like a natural way to go.
Is there a tool like that?

Thanks!

Related Discussions
...
  • Düzenlendi

There isn't currently. What modifications to the JSON are you doing? I'm curious because I'd like to judge how common this workflow is.

Hi Nate, sure, we are doing the following:

  1. An artist uses Spine to create skeleton body with an item that stem from one specific bone, let's say a hero body and a helmet.
  2. We export that to json.
  3. We use our utility to seperate item from body into two json files, one for body and for item (or two items).
  4. Again, in Spine an artist creates a copy of entire skeleton and creates a different item (a hat with it's own bone structure)
  5. Repeat steps 1-3 for 20 items
  6. Also, we create multiple hero bodies (similar skeleton yet different enough), lets say we have 10 of those

We end up with 10 bodies and 20 items instead of 200 items/combinations. This is a simplified example since we also have weapons and a few more item bones for different type of items.

Our utility is used to separate body from item so we can make any combination during runtime. We modified Cocos2d-x runtime to support skeleton attachments which we later attach to before mention specific bone (slots on that bone). Some bone renaming is also involved, I believe all the coordinates and animation transformations are kept as they are.

We cannot have this separated in Spine as our artist must see and work on a plethora of animations, also there is no support for skeleton attachments / or bone group (no real need for a separated skeleton, an interchangeable bone group would do the job). This would be a feature that would make Spine THE tool (copy-paste to different skeleton would also be nice to have 🙂 ).

In the end we managed to establish a workflow that works for us, but it could be faster and more natural.

To wrap things up, we end up with json but binary is faster so we need that conversion added to build/publish pipeline.

I believe a lot of Spine users would welcome this features. Thanks!

p.s. I would love to here some feedback about our workflow, is there a better way?

2 ay sonra

We have a similar workflow as gen's, really wish we have this commandline tool, too.

bir ay sonra

This workflow would be massively helped out if it was possible to load and display another spine file to a bone in the active scene or vice versa.

That would be pretty tough to do though. thoughts

Maybe just the ability to set another Skeleton's bone as the cosmetic 'origin' for a 2nd skeleton in the same spine file?

Thanks gen for the explanation, and sorry for the delay. In version 3.5.01 you may export JSON or binary as normal except specify a .json or .skel file instead of a project file. Spine behind the scenes will create an empty project, import the JSON or binary file into it, then perform the export as normal using that project. This allows you to effectively convert JSON to binary or binary to JSON.

@Xelnath, an attachment that is a whole skeleton is the right solution. Until then, it can only be done at runtime.

2 ay sonra

hi,

we would like a json to binary export tool as well. Similar to another person here we have tools that read the json but we would like to convert to binary to the version we include in the final build.

thanks
andre

andreparodi, Spine can do that, as explained in my post above yours.

Spine 

---

export /path/to/export.json 

---

input skeleton.json 

---

output skeleton.skel
6 ay sonra

Hello Nate,

I'd like to upgrade my Spine from 3.2.01 to 3.5.51.
So, I upgraded Unity spine runtime from 2.3 to 2.5.
Now, I need to re-export all my old spine binaries in Unity project from Spine 3.5.51, 'cause new runtime doesn't accept old binaries.

I want to make a script that executes above command with different skeleton.skel files.
All I need is a re-exported binaries from an old binaries. No atlas.

This is what I tried.

  1. Imported old binary in Spine 3.5.51.
  2. Saved binary Export setting json file. (ex. setting.export.json)
  3. Tried a following command.

Spine


export setting.export.json


input oldSkeleton.skel


output outputFolderPath

But it does not work...
Is it possible to import binary and export binary from command line?

Thanks!

Data Import in the editor is expecting JSON or binary in the latest data format. Sometimes older JSON can be accepted, but binary is more sensitive to changes and is less likely to work.

Compatibility happens at the Spine project level


new versions of the Spine can open projects saved with ANY older version of Spine. So ideally you simply re-export your projects with a newer version of Spine.

Hello Nate,

Thank you so much for your reply!
Okay, I will re-export binaries from Spine project files.

It's just that if I could simply search all the .skel.byte files in Unity project and re-export them all via script, I don't have to hunt down the original .spine project files and put them in each locations in Unity project. ;-)
Anyhow, I appreciate this command line option.
Thank you!

You definitely want to keep the project files safe, as it's the best way to regenerate the JSON or binary data. Trying to do it with only old data files is wrought with peril. 🙂

9 ay sonra

Hi there!

Hope you are doing good! I was looking for a way to convert lots of spine json files to .skel files and came across this post.

You mention that in spine 3.5 and above, we can use the command line with json file as input and output it as .skel. I tried doing this but it doesn't work for me.

Following is the command I am using to test this out:

/Applications/Spine/Spine.app/Contents/MacOS/Spine 

---

input spineboy.json 

---

output test.skel 

---

export settings.json

But I keep getting the following error:
Input path must be to a Spine project file for export

I went through the changelog for Spine 3.5 and it does say that:
CLI exporting can now take a .json or .skel instead of a .spine project file to convert a Spine skeleton data file from JSON to binary or binary to JSON.

Therefore, I am wondering if I am making a mistake in typing in the command or are there any limitations on the JSON file to use? Any help will be greatly appreciated! The settings file I am using is generated from Spine editor saved through 'Export->Binary->Save' 🙂

You may need to update your Spine launcher by downloading and reinstalling Spine. The error in the latest launcher is "Input path must be a .spine, .json, or .skel file for export:".

FWIW, in 3.7.14-beta (will be released soon) you can import a folder of JSON or binary files using the Data Import dialog.
 Loading Image

6 gün sonra

Dear Nate!

Thank you so much for your prompt response. I apologize for my delay in getting back to you.

After updating the launcher, it worked but there was another issue. I am getting errors when it tries to convert json to skel which I assume is because the json was generated from an older spine version (3.2.01). I need to keep that version intact because we use an older version of the Spine Unity Runtime.

In the end, I tried to locate all the spine project files and regenerate the skel through them. These spine files are the same files that were used to generate the json files earlier (that we now wish to convert to skel for optimization). Since I don't need the assets or atlas (as they were generated with the earlier json), I am just using the .spine files without the assets. But before generating a skel file through them, in order to be 100% sure that the json is identical to what we had before, I am generating the json files again and comparing them against the earlier json files.

Fortunately, once I tested all the generated json files against the earlier json files they are identical EXCEPT for the width and height variable under "skeleton" which is 0 in the new files because I assume I didn't have the assets. Now my question is, does it matter in Unity if the width and height in json or skel are set to 0 and everything else is the same? We already have the atlas files. Our next step after verifying the generated json and new json will be to generate the .skel files.

I hope I am not confusing you! Let me know if you need any more details. Thank you so much again.

When generating binary files, you must use the version of Spine that your Spine Runtimes work with. Even if the JSON is the same when exporting from a newer version of Spine, binary is a completely separate format and much more sensitive to changes. ANY change to the binary format will cause older runtimes to no longer be able to load it.

The skeleton width and height values are not important, unless your own runtime code relies on them.

Thanks again for your prompt response, Nate!

Thanks also for letting me know the importance of keeping the same version for spine.

The first thing I am doing is to regenerate all the JSONs using spine, so I can compare with existing JSON and validate that the spine file is indeed the correct one to use. I am doing it using the following command in Terminal:

/Applications/Spine/Spine.app/Contents/MacOS/Spine 

---

input file.spine 

---

output file 

---

export settings-json.json -u 3.2.01;

Once the JSON is generated, I will compare it against the JSON I already have in our game using this super-helpful tool called jd :https://github.com/josephburnett/jd

If the only difference in my old JSON and newly generated JSON are width and height, I go ahead and generate the skel files as follows:

/Applications/Spine/Spine.app/Contents/MacOS/Spine 

---

input file.spine 

---

output file 

---

export settings-skel.json -u 3.2.01;

You can see in both cases I am using 3.2.01 for Spine which is what we used in the past. The Spine Runtime version in our game in Unity is 2.3 I think. The only difference might be the Spine launcher version which is the latest one I am using to generate the above. I hope that doesn't cause any issues.

In the end, we will still have to test all the assets and animations! That will be the definite way to ensure that it is all working as expected. 🙂

OK, great. I just wanted to be sure you were using the same Spine version for export as for runtimes. The -u 3.2.01 does it, so you should be good!