- Home /
javascript deserialize list of custom class
Hi, I can't get the valid syntax for this in javascript:
var playerList = new List.<Player>();
var jsonData : String = '[{"id":0,"forename":"aaa","surname":"bbb"},{"id":1,"forename":"ccc","surname":"ddd"}]';
playerList = Serializer.Deserialize.<List.Player>(jsonData); // Here's the problem
// List<Player> playerList = serializer.Deserialize<List<Player>>(jsonData); // This should be C# if I got the code correct from examples which I googled.
public class Player {
var id : int;
var forename : String;
var surname : String;
function Player() {
}
}
Error is "BCE0018: The name 'List.Player' does not denote a valid type ('not found')."
So please, how is the correct syntax for JS? Thanks
Answer by jenci1990 · Mar 22, 2015 at 04:42 PM
Use space after "" like this:
playerList = Serializer.Deserialize.< List.<Player> >(jsonData);
Wow! Just got back at my code and implemented this. Thank you so much!
Now the question is: How could I know that syntax? Where's a good place to get info like this?
When i have similar problem, I can't find any place about this. I try this syntax and it's worked. :)
Ok, thanks. I tried a lot of things but didn't know about the "spave" method ;-)
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Why am I getting this BCE0019 error? ScreenToWorldPoint' is not a member of 'System.Type 1 Answer
JavaScript - slow motion ? 1 Answer
Player sticks to ground occasionally after trying to jump 0 Answers