-
Notifications
You must be signed in to change notification settings - Fork 3
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
decoding empty string results in 0 #5
Comments
I found the bug, but I'm not sure how I want to handle it. The intended code was supposed to throw an error, but thinking about it now, I'm not sure if I want to do that as it is a valid condition. I currently throw errors on bad input, which I'm also thinking was a bad idea (throwing on encoding is fine as that's a programming error, but upon decoding? That's not the programmer's fault but the sender's---at least, that's my thinking). |
It now throws an error on no input, which was the original intent. |
Is there something I can encode to get "nothing"? |
That's an interesting question---by "nothing" to you mean a 0-byte blob of data? Or some CBOR value that represents "nothing"? I never thought about the former (what would that even mean?) and the later can be accomplished by calling cbor.SIMPLE.null(), which returns a CBOR null value or by calling cbor.SIMPLE.undefined(), which returns a CBOR undefined value. I'm not sure what would be better. |
That's what I originally attempted. But I now see that that is probably incorrect
I guess I was looking for |
But that works. |
The text was updated successfully, but these errors were encountered: