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

Cereal failing to decode data that it encoded successfully #24

Open
einsteinx2 opened this issue Nov 8, 2016 · 3 comments
Open

Cereal failing to decode data that it encoded successfully #24

einsteinx2 opened this issue Nov 8, 2016 · 3 comments

Comments

@einsteinx2
Copy link

Hi, I'm currently using Cereal 1.4.0 in a Swift 3 project on OS X ( I created an OS X target, which has been working fine for me so far, with the exception of this issue).

I'm not sure if my recent upgrade to Swift 3 and Cereal 1.4.0 introduced this issue, or not, because I'm sure it worked previously but not sure exactly when it stopped working.

Anyway, I'm serializing an array of Swift objects, in this case the array includes only one object.

The error I'm getting is ".Array / .Cereal / .Dictionary not expected", so of course at first I thought the problem was that I was deserializing an array (even though that should be supported). However on closer inspection, the issue is with the decoding of a property in the object which is a dictionary. parseEncodedDictionaryString is being called, which calls iterateEncodedValues, which eventually calls parseEncodedDictionaryString. This then fails decoding the key, apparently because the key's type is .cereal.

Here's all the data that's failing in parseEncodedDictionaryString:

keyType = CerealOSX.CerealTypeIdentifier.cereal
keyValue = "k,8:rawValue:s,4:more"
type = CerealOSX.CerealTypeIdentifier.string
value = "100"

Any idea why this is failing? Also what does the key type of .cereal mean and why is that unexpected? I'm getting no errors during the encoding/serialization, only in decoding. Is this a bug in Cereal, or something I'm doing wrong?

Any help is greatly appreciated, thanks!

@ladvoc
Copy link

ladvoc commented Jan 14, 2017

Same issue.

@einsteinx2
Copy link
Author

Never figured out a fix, ended up just not using Cereal.

@tengyifei
Copy link

try cerealDecode instead of decode

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

3 participants