Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add a json schema file #82

Open
mundusnine opened this issue Aug 2, 2022 · 3 comments
Open

[Feature Request] Add a json schema file #82

mundusnine opened this issue Aug 2, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mundusnine
Copy link

Hyperlap2d seems very promising for people wanting to make a custom engine and having a generic editor, but right now if I want to make a "runtime" for the output of hyperlap2d I need to generate a scene/world and reverse engineer the format.

Another project called ldtk fixed this issue by offering a json schema file following the json schema format. This enables to validate json files on export(for testing) and enables other projects to make importers/parsers for the json output of ldtk. Also, quicktype enables to automate the process of making parsers for multiple languages(including java) when using json schema files.

@mundusnine mundusnine changed the title [Feature Request] Add a json shema file [Feature Request] Add a json schema file Aug 2, 2022
@fgnm
Copy link
Member

fgnm commented Aug 2, 2022

Uhm totally agree on that! I didn't know about the existance of Json schema, I can make it this weekend, thanks for point it out :)

@fgnm
Copy link
Member

fgnm commented Aug 16, 2022

Hi @mundusnine sorry for my late response but unfortunately I was busy on other stuff.. I've looked into JSON schema and it turns out pretty more difficult to implement than expected. The issue is that JSON Schema is made to define static JSON documents, in the past (like the old Overlap2D) this program exported things with a fixed JSON format, but since the first Beta JSONs are meant to be dynamic in order to not give any constraints for plugins that might be developed in future by anyone else. Another difficulty I'm having is describing the "default" value of a field. In HyperLap2D Json anything is not required but everything has a default value in case the field is missing in the JSON. This is how libGDX Json serializer works and it's very smart because those JSONs tends to explode very quickly in terms of dimensions, stripping all default values is not only good for file size but also for upgrades with backward compatibility.

Saying that, I'm totally still for a way to describe HyperLap2D JSONs both for validation and for helps other runtimes to parse them but at moment I need some suggestions how to properly do that.

@fgnm fgnm added enhancement New feature or request help wanted Extra attention is needed labels Aug 16, 2022
@mundusnine
Copy link
Author

Hi @fgnm,

Thanks for having a look at this. To adress your issues I might of found some guidance on ways we could go.

For the "fixed" part of JSON schema, there is actually a way around that by having subschemas and conditionals.

For "default" values, have a look in the annotations section in this document.

Now, the thing I wonder about is how dynamic are the JSON files, are there any necessary fields or are all fields totally dynamic and generated by the editor ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants