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

Use fixed map() representation of JSON objects #118

Open
seriyps opened this issue Feb 14, 2022 · 0 comments
Open

Use fixed map() representation of JSON objects #118

seriyps opened this issue Feb 14, 2022 · 0 comments

Comments

@seriyps
Copy link
Collaborator

seriyps commented Feb 14, 2022

Right now Jesse supports multiple Erlang representations of JSON object type: map() / proplist / {proplist()} / {struct, proplist()}.

It used to make sense before maps were introduced in OTP-17 in 2014. But now, over 7 years since then I think most of the libraries and systems are using maps for object representation. Jesse supports maps since 2016. Even jsx started to return maps by default since v3.0.

It should simplify the code quite a lot, because we would be able to use pattern-matching and is_map in guards, would be able to drop unwrap function usage, maybe even use maps:iterator() (OTP-21+) for the validator's "main loop".

We may provide some helper functions which would recursively convert legacy object representation to maps and back for those who are unable to migrate for some reason (by the cost of lower performance for such users). But I doubt that such legacy systems are going to bump the Jesse version anyway.

Maybe it would make sense to release a new tag with draft-06 support just before this change is implemneted, so those who can't update their JSON representation can still benefit from draft-06 implementation.

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

1 participant