0

I am trying to create a user that has a username, password and playlist. The playlist should be an array that holds a json objects which looks like {"Songname": upvotecount} which are both a string and number. When I try to create the object, the username and password are created fine, but the playlist won't create properly. I would appreciate any help on how to create this object properly. Thanks for the help in advance.

var user = new User({
    username: user,
    password: pass,
    playlist: [{String : Number}]
});
2
  • 1
    your contents of your playlist array is not valid javascript code. The object getting created in your array is invalid. Should be {songname: <value>, upcountvote: <value>}. You did not provide any keys in the original object definition Commented Jan 29, 2016 at 22:09
  • Thank you! I am new to JSON and now understand better how to work with it. Commented Jan 30, 2016 at 6:09

1 Answer 1

1

The contents of your playlist array is not valid javascript code. The object getting created in your array is invalid. Should be {songname: <value>, upcountvote: <value>}. You did not provide any keys in the original object definition

var user = new User({
  username: user,
  password: pass,
  playlist: [
    {
      songname: "a song",
      upcount: 1
    }
  ]
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.