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

_hxcls must be first property in object #16

Open
jdharrison opened this issue Jan 28, 2015 · 2 comments
Open

_hxcls must be first property in object #16

jdharrison opened this issue Jan 28, 2015 · 2 comments

Comments

@jdharrison
Copy link

In order to leverage haxe class parsing you must have the "_hxcls" property set as the first entry, and this is an unintuitive requirement (and very restricting).

{"float":0.5,"_hxcls":"test.ClassTest"}
should work the same as
{"_hxcls":"test.ClassTest","float":0.5}

If I can find the time I shall add it in, however: any parser operations should be checked for first before parsing other fields.

@JWambaugh
Copy link
Owner

The serializer should always include the _hxcls property first, so in the use case of parsing json that was serialized with the TJSON serializer this should not be an issue.
Checking the entire string for the existence of a _hxcls property would require a 2-pass parsing approach that would unfortunately hurt performance. I'm not sure if the benefit would outweigh the cost.
In what use case are you finding the need to have _hxcls property not be the first property?

@jdharrison
Copy link
Author

The use case is having a spreadsheet with game data (potentially multiple people editing it, increasing possibility of human error) which is exported to a JSON file. In addition, it is easy to have occurrences of bugs with any data that you are loading that could not be serialized by TJSON initially (since any fields before that value stay at their default values). Lastly, there is no error reporting when it isn't first so it's a pretty silent failure.

Instead of doing 2 passes on the parsing, perhaps it'd be better to check that if this is not the first object property assigned then to re-assign the properties within this object that came before "_hxcls", sure it's less performant but it doesn't fail -- and can allow for data optimization later.

However, you make a good point with performance since this feature really depends on the needed implementation; I'll probably just fork off since this is more of an issue with my specific situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants