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

Problem Deserializing a list of player #875

Closed
robinmoon2 opened this issue Nov 29, 2023 · 5 comments
Closed

Problem Deserializing a list of player #875

robinmoon2 opened this issue Nov 29, 2023 · 5 comments

Comments

@robinmoon2
Copy link

Hello, I have a problem.
I have a code that can write this kind of YAML file :

  • name: p1
    timer: 60
    score: 1
  • name: p2
    timer: 60
    score: 1
    Where one (name,timer,score) is for 1 player which is a class in my code.

I use the serializer to write the YAML file and it works pretty well. But when I need to read it with the deserializer and put it in a list of players it doesn't work and I have the error message following :
Unhandled exception. (Line: 1, Col: 3, Idx: 2) - (Line: 1, Col: 3, Idx: 2): Exception during deserialization.

I put the 2 function below, if someone have the solution it will really help me out.

image

@EdwardCooke
Copy link
Collaborator

Can you your entire player class? There should also be more details on that exception as well.

@robinmoon2
Copy link
Author

So this is the player class :
image

Then I built the PlayerList class :
image

And this is where I call the function to Read and Write on the YAML File.

The function Writing works perfectly but not the reading one.

What do you mean by "Can you your entire player class" ?

I don't find any more details about this exception on the repo.

@EdwardCooke
Copy link
Collaborator

You need a parameterless constructor on your player class. Add that in there and it should work.

@EdwardCooke
Copy link
Collaborator

Did that resolve the problem?

@robinmoon2
Copy link
Author

Yes this solves the problem at perfection.

Thanks you a lot :)

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

2 participants