• Bugs
  • Unity import error on non-spine json files

Related Discussions
...

Importing a non-Spine json file that has a top level array (and thus starts with a square bracket) causes an error in Unity:

Failed to read 'helloworld'. Extension is '.json' but content looks like binary 'skel.bytes' file.
Did you choose the wrong extension upon export?

UnityEngine.Debug:LogError (object,UnityEngine.Object)
Spine.Unity.Editor.AssetUtility:ImportSpineContent (string[],System.Collections.Generic.List1<string>,bool) (at Packages/com.esotericsoftware.spine.spine-unity/Editor/spine-unity/Editor/Utility/AssetUtility.cs:295)
Spine.Unity.Editor.AssetUtility:HandleOnPostprocessAllAssets (string[],System.Collections.Generic.List
1<string>) (at Packages/com.esotericsoftware.spine.spine-unity/Editor/spine-unity/Editor/Utility/AssetUtility.cs:113)
Spine.Unity.Editor.SpineEditorUtilities😮nPostprocessAllAssets (string[],string[],string[],string[]) (at Packages/com.esotericsoftware.spine.spine-unity/Editor/spine-unity/Editor/Utility/SpineEditorUtilities.cs:98)
UnityEditor.AssetPostprocessingInternal😛ostprocessAllAssets (string[],string[],string[],string[],string[]) (at /Users/bokken/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:165)

Expected: Importing a non-Spine json file with a top-level array will not cause the Spine Importer to throw an error.

SkeletonDataCompatibility.IsJsonFile() checks for a curly brace as the only valid opening character for a json file. See
https://stackoverflow.com/questions/5034444/can-json-start-with

Move the attached json file to the Resources directory and re-import for a repro.

Tested with: spine-unity-4.0-2021-09-15.unitypackage

Sorry for the troubles and thanks for reporting with a reproduction package provided up front, this is very helpful in general.

Please note that this bug has already been fixed rather recently, and you are using a unitypackage older than this fix.
The issue was tracked under this issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1992
Please let us know in case the latest spine-unity package does not resolve your issue, then we're of course happy to fix that as well.