❔ Deserializing Json to class
I have a text file wich I save my json to but when I try to deserialize it it never works. My json that is serialized looks fine bcs it even works when I run my json through an online converter. My Library class has 1 property that is an array of Movies.
15 Replies
And my debug always returns 0
I ran some non-JSON through an online converter and it worked fine. When I tried it in C#, I got frustrated because it didn't work... because it wasn't JSON.
Example:
in https://json2csharp.com/ works just fine, but it's not JSON.
So you're probably best off checking the JSON.
This is the Json I am trying to convert
I Serialized it like this
File.WriteAllText(FileName, JsonConvert.SerializeObject(Lib));
@JamesK.Polk I am really stuck do you have any idea?
I don't know how to deserialize to a class like that.
My models are usually just super simple/dumb classes.
You're opening a stream during deserialization. I've never seen that before.
I actually have a class where I serialize/deserialize stringified images, but I don't know how to help you with the way you want to do it.
What are stringified images?
iVBORw0KGgoAAAANSUhEUgAAAE4AAACZCAYAAACBkQyKAAAABGdBTUEA...
oh so just a string
I could try that
I am just stuck on saving an image to json
The image I just provided is in a JSON file I store
then I compress the entire file for the user so they can transfer something smaller
9256 kb => 552kb compressed
And how did you convert the Image to a string?
And you can serialize /desirialize BitMapImage just fine?
Yeah. I just hacked a lot of stuff together. I haven't looked at these methods since.
aight ty man
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.