Skip to content

allow JSEN to be initialized from a type-erased JSEN instance#2

Merged
rogerluan merged 2 commits intorogerluan:masterfrom
loganmoseley:master
Feb 9, 2022
Merged

allow JSEN to be initialized from a type-erased JSEN instance#2
rogerluan merged 2 commits intorogerluan:masterfrom
loganmoseley:master

Conversation

@loganmoseley
Copy link
Copy Markdown
Contributor

Currently, JSEN(from: jsen) -> nil. This allows for JSEN(from: jsen) -> jsen. This is analogous to Int(42) -> int, not -> nil.

This allows the initializer to accept a JSEN instance that's been type-erased. This'll come up if the JSEN value has been passed through some function that erases it to Any. In my case, this came up when I passed my "JSON object" [String: JSEN] into an adaptor function that took [String: Any].

Thanks for considering!

Copy link
Copy Markdown
Owner

@rogerluan rogerluan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice catch!
Thank you for your contribution @loganmoseley , including updating the tests 🤗

Merging this in! 🚀

@rogerluan rogerluan changed the title Slightly relax JSEN.init(from: Any?) allow JSEN to be initialized from a type-erased JSEN instance Feb 9, 2022
@rogerluan rogerluan merged commit 586c395 into rogerluan:master Feb 9, 2022
@rogerluan
Copy link
Copy Markdown
Owner

This has been released in v1.1.2 🚀

@loganmoseley
Copy link
Copy Markdown
Contributor Author

You're on the ball, Roger 👍🏼 Thanks for the concise, nice library.

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

Successfully merging this pull request may close these issues.

2 participants