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

Json Serialization Error #94

Closed
chrispy2day opened this issue Feb 16, 2015 · 3 comments
Closed

Json Serialization Error #94

chrispy2day opened this issue Feb 16, 2015 · 3 comments
Labels

Comments

@chrispy2day
Copy link

I'm trying to use Akavache with Splat for image caching in a Xam Forms project. When unit testing, I kept getting the following error any time I access the cache:

Unexpected token while deserializing object: PropertyName. Path 'Value.Width'.

I created a simple console app that experiences the same problem when using the GetImage method or gets an invalid image exception when using GetImage2. The image is a just a sample I pulled from Google images, but is a valid image. The example App can be found in my Git repo

@shiftkey
Copy link
Contributor

@JC-chris I've opened a PR against the demo repo to explain a bit more about how Akavache serializes/deserializes images:

chrispy2day/SplatImageProblemExample#1

  • in the first test method, serializing IBitmap won't serialize the image bytes correctly. I'd recommend against doing that - you can see in the sample how to serialize the bytes directly (like Akavache does under the hood).
  • in the second test, I believe Akavache was using the cached (invalid) bytes from the first test method (because the URL is used as the key unless you specify it explicitly) and it was unable to transform these bytes into a valid image format.

In general, I'd recommend using the LoadImageFromUrl helper methods, as this will take care of the boring grunt work.

@chrispy2day
Copy link
Author

Thanks, yes, now that you point it out serializing the bytes makes more sense anyway. Really appreciate your assistance, thanks so much!

@shiftkey
Copy link
Contributor

@lock lock bot added the outdated label Jun 24, 2019
@lock lock bot locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants