Closed jesdi closed 6 years ago
Thanks for the proof-of-concept.
Maintaining the documentation as part of the JSON schema is not easier in my opinion as the format is very verbose.
Could you elaborate with a concrete example how the schema helps you in modifying the export JSON more than what's already possible?
Migration between versions based on schema merges are an ideal that I have yet so see realized in any form, including JSON-LD, XML Schema and other formal format descriptions. It looks good on paper, but never works in reality, as the schema only describes the form, but not the semantics.
The same is true for validation. The semantics of the data stored inside a JSON file following a schema can not be verified, only it's form.
I do have quite a bit of experience with various schema DSLs in different contexts (service orchestration, complex configuration, serialization, etc.). At the end of the day, any benefits derived from the schema were always far outweighted by the downside of maintaining the schema itself. And most of the benefits did never materialize.
That's my 2 cents, I'm leaving this to @NathanSweet to decide.
I have to agree with Mario. Maintaining the JSON documentation is painful, as is maintaining the schema. I'll close this issue for now, but we can continue discussion here and would still like to see concrete examples of the schema benefits. I don't expect it to help for version migration and I don't feel validation isn't generally very useful. Showing how it is useful for editing JSON skeleton data might be interesting.
Thank you a lot for the quick answer!
I Few things here:
Maintaining the documentation as part of the JSON schema is not easier in my opinion as the format is very verbose.
Yes, it's true... but you can generate most of the JSON schema's information automatically, for example using https://jsonschema.net. And I think is really useful also to generate docs/forms automatically.
The semantics of the data stored inside a JSON file following a schema can not be verified, only it's form.
Yes, but you can at least validate some information like max/mins values, types, number of elements of arrays, objects, etc.
Why I need a JSON schema:
I am currently working in a customisable pipeline for processing assets following certain steps(validation, clean unused parts, texture_generation, compressing, etc). Right now it works with Adobe Flash, Unity and more recently started to test Spine. The thing is that Adobe Flash gives you an API using jsfl, which is awful, but at least kind of work... As you guys does not give such thing I created some code to do the modifications directly to the .json file. (remove animations, clean unused images in animations, etc).
This is how I remove the animations from a JSON removing also all the slots/skins/attachments used only in that animation.
class SpineAnimationModifier(object):
def load_from_json(self, json_data):
json_schema_validate(json_data, schema=schema)
....
#Some modifications of the data
def erase_animations(self, animations_to_erase):
...
def to_json(self, ...):
....
# Validate that after all the modifications everything is ok:
json_schema_validate(self.json_data, schema=schema)
return self.json_data
spine_animation = SpineAnimationModifier().load_from_json(...)
spine_animation.erase_animations(["walk", "jump"])
json_data = spine_animation.to_json(...)
So, the only way to be sure that after an Spine's update it doesn't break everything was using a JSON schema. Also I could keep the track of the new updates in the format you guys add and sometimes are not 100% updated in the web. This is working right now, but I am kind of stuck mainly because this bug http://esotericsoftware.com/forum/Spine-command-line-trouble-10308 I reported to you today.
Maybe you guys could give me some advise of how attack this problem. Sorry for the long answer but I think that a little bit of context was necessary.
Thank you a lot!
Validation is helpful only for your JSON modifications being correct, which is only really useful during the development of the modification code. I'd say not being able to validate is pretty minor, since you'll find out if your modifications are incorrect when you try to load the data. Also, as badlogic mentioned, even if validation succeeds your modifications could still be wrong. There is no assurance that data which validates will actually load, though it does increase the likelihood.
FWIW, here is some JSON modification code using Java and libgdx.
With JSON schemas:
Just bellow there is a (WIP) version of the Json Schema I have generated based on the docs.
spine_json_schemas.txt
Will be really helpful to have this added to the doc/code_base.
Thanks in advance!