-
Notifications
You must be signed in to change notification settings - Fork 48
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
Ambiguous load/loadAll semantics when dealing with broken input #682
Comments
I found another case where ion-js surprises me: if you feed (Found with 4.1.0) |
The 1. The input is valid Ion with one or more valuesIn this case, 2. The input is valid Ion with zero valuesIt is possible for an input source to represent an Ion stream without any values. For example:
In cases like these 3. The input is invalid IonThe stream cannot be interpreted as Ion. We cannot say whether or not it contains any values because it cannot be decoded. In this case, we throw an exception. Note that an Ion reader (and by extension, the title yearPublished cost
"The Old Man and the Sea" 1952 9.95 By coincidence, this file is also a valid Ion text stream. Instead of being two rows with three columns each, an Ion reader would consider it to be a series of six top-level values: three symbols, a string, an integer, and a decimal value. For this reason, it is the user's responsibility to confirm that the data they are passing to the
This is definitely not the expected behavior; |
Thanks for the detailed explanation! Maybe the docs on load/loadAll can be expanded a bit more on this front (since it caused user confusion). |
Docs on
load
(similarlyloadAll
) saysHowever, if I feed a piece of broken input into
load
, I get exception rather than a null value I was expecting. I would argue if an input cannot be loaded as an Ion value, it should be regarded as a "no value is found" situation.Repro: https://runkit.com/embed/unc0ogmrc1fq
The text was updated successfully, but these errors were encountered: