Search code examples
c#json.netserialization

Deseralizing JSON Issue... My code or My File?


I have a JSON I'm trying to deseralize in C#. I have set up several classes to model the data format of the JSON contents. I have built some data classes for other JSON's. This one is giving me issues... not sure if the guys' python script is outputting it correctly... only been deserazliing json for a month now.

I attached what I think is the most insightful error as a screenshot:

enter image description here

I attached screenshots of my data classes:

enter image description here

Here is the JSON content:

[{'title': 'Liked Music', 'playlistId': 'LM', 'thumbnails': [{'url': 'https://www.gstatic.com/youtube/media/ytm/images/pbg/[email protected]', 'width': 192, 'height': 192}, {'url': 'https://www.gstatic.com/youtube/media/ytm/images/pbg/[email protected]', 'width': 576, 'height': 576}], 'description': 'Auto playlist'}, {'title': "_80's", 'playlistId': 'PLiK4FwdJe_H-fq0F8GRQabnlpha3_cR7H', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/JLTYHLRhDtVwyWfqEzQJVtrvGGAWnSBVVrboT44McwAcb9OXAmbLm5bfnOe66IQqrDrMtRxk0A=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/JLTYHLRhDtVwyWfqEzQJVtrvGGAWnSBVVrboT44McwAcb9OXAmbLm5bfnOe66IQqrDrMtRxk0A=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 5 tracks', 'count': '5', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Abmience - Sci Fi Highway', 'playlistId': 'PLiK4FwdJe_H-nYorrTRglD4LVM6wwx2Zy', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/JTdrDS4UN8UyJKC-bzRHYqeZXKK7xbCn0vsecySKW4ipdX5HIA2O4AN0x7fIUvfvSbZ4-MxsqOs=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/JTdrDS4UN8UyJKC-bzRHYqeZXKK7xbCn0vsecySKW4ipdX5HIA2O4AN0x7fIUvfvSbZ4-MxsqOs=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 10 tracks', 'count': '10', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Absolute Favorites', 'playlistId': 'PLiK4FwdJe_H8eBAz3dDO_LAi7-f5sMIKL', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/nN1_6zyBQoOIRb3yhwYbF18nVEmcy3sJ__K91AzTExOlvCuYCcYm7HV0egvSZPxgDpsrBkCn8g=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/nN1_6zyBQoOIRb3yhwYbF18nVEmcy3sJ__K91AzTExOlvCuYCcYm7HV0egvSZPxgDpsrBkCn8g=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 7 tracks', 'count': '7', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_All Time Favorties', 'playlistId': 'PLiK4FwdJe_H9Tp8Ci0wfVm6y1x_KTUo0D', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/CQjA03sb3X90knE0wY3t5ijPBQmUJxoDs25PhhTZSSLDgn_ruvNJ6kMC2ujyuvSyCFMRbIvuoEvF=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/CQjA03sb3X90knE0wY3t5ijPBQmUJxoDs25PhhTZSSLDgn_ruvNJ6kMC2ujyuvSyCFMRbIvuoEvF=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 24 tracks', 'count': '24', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Earth Lounge', 'playlistId': 'PLiK4FwdJe_H-qGasLNsJkxrJPLWG7SBtl', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/tFKCmdqftY9H3s6Cu6v8Q062UDbfiuZEqlXKpY5yLk5dJ-7blW8LUdx87NtMMCttHB8XtEwNV0s=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/tFKCmdqftY9H3s6Cu6v8Q062UDbfiuZEqlXKpY5yLk5dJ-7blW8LUdx87NtMMCttHB8XtEwNV0s=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 4 tracks', 'count': '4', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Earth Treks', 'playlistId': 'PLiK4FwdJe_H8ByEnFOchYpq9lC7GhtIiy', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/AZcHcizC-sYJnp3w2Kj__AZe1H0qIXGN24XAdM70w-ZqEpfPACx7qcEmE-COFpCJaSFYgeCa3155UGcs=w226-h226-l90-rj', 'width': 226, 'height': 226}, {'url': 'https://lh3.googleusercontent.com/AZcHcizC-sYJnp3w2Kj__AZe1H0qIXGN24XAdM70w-ZqEpfPACx7qcEmE-COFpCJaSFYgeCa3155UGcs=w544-h544-l90-rj', 'width': 544, 'height': 544}], 'description': 'Amocles • 1 track', 'count': '1', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Fallout Radio', 'playlistId': 'PLiK4FwdJe_H9J_VLAXHaQCWRd93ojiAY8', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/68YZZE1_t1Y617OYLfqcq90_TuQ1lIE8kSKOSj4akpyTD5x78CiGtQzTA1Rpczh59KQNHEb_yYE=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/68YZZE1_t1Y617OYLfqcq90_TuQ1lIE8kSKOSj4akpyTD5x78CiGtQzTA1Rpczh59KQNHEb_yYE=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 2 tracks', 'count': '2', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Quiet Exploration', 'playlistId': 'PLiK4FwdJe_H9CAqR0L-UcbUyl0f8Z6rSQ', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/f13T4u63dFqnpmrPmGesxcKg_5yg8YIrOkI89WccnOgOtkKMHG3JXcZPvAXXHike7G-TX7XPMAk=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/f13T4u63dFqnpmrPmGesxcKg_5yg8YIrOkI89WccnOgOtkKMHG3JXcZPvAXXHike7G-TX7XPMAk=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 2 tracks', 'count': '2', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Relaxation', 'playlistId': 'PLiK4FwdJe_H_RsU_w4xQNkXmJNRwLFOAv', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/x6AN51K3COw1Nqzn63hwEZYntpZC4rSssivr7b-oGuYrmdPwu8DW7-3Jbwzb22Hn86RgO5qNMQ=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/x6AN51K3COw1Nqzn63hwEZYntpZC4rSssivr7b-oGuYrmdPwu8DW7-3Jbwzb22Hn86RgO5qNMQ=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 38 tracks', 'count': '38', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Sci Fi', 'playlistId': 'PLiK4FwdJe_H_kW5zuBgH5j3lKEUajwvMi', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/TEmPrYD0BxbKjMaR6Lti9Q9D5z7GAqQ310L2Q_nQxfnO5fmHoezf-72npIE9wRhfKQtmFl8Ob2Ca=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/TEmPrYD0BxbKjMaR6Lti9Q9D5z7GAqQ310L2Q_nQxfnO5fmHoezf-72npIE9wRhfKQtmFl8Ob2Ca=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 4 tracks', 'count': '4', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Space', 'playlistId': 'PLiK4FwdJe_H_tEQoNoK8dDL_5lYRqrd0Y', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/JkkZ53CITspJxnLIqtcB9iruxjfu8U0r2xs07t_bCYehcSOA9dusD4stMh1bPQTV4HkJNdYPHA=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/JkkZ53CITspJxnLIqtcB9iruxjfu8U0r2xs07t_bCYehcSOA9dusD4stMh1bPQTV4HkJNdYPHA=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 20 tracks', 'count': '20', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Space Club', 'playlistId': 'PLiK4FwdJe_H_sYRqmOf8Ery4Eq-sQUAZ3', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/2z5jPM5XZgDU6uMifyzoQ3VB1pyHrIM4dV4cSKdX77wvvLQdnFD_lmH6nVLRV30PvnTPICmV8d4=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/2z5jPM5XZgDU6uMifyzoQ3VB1pyHrIM4dV4cSKdX77wvvLQdnFD_lmH6nVLRV30PvnTPICmV8d4=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 1 track', 'count': '1', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Ambience - Space Lounge', 'playlistId': 'PLiK4FwdJe_H9swQRrp574dTCKT5L1oPVS', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/07qHt5Um6SqEU0ugqQmiLwE_ijO5YASdQtmwpEgoJK4LVQhPtDnbzGa0UGidTiBH0WFfnD2izw=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/07qHt5Um6SqEU0ugqQmiLwE_ijO5YASdQtmwpEgoJK4LVQhPtDnbzGa0UGidTiBH0WFfnD2izw=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 9 tracks', 'count': '9', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Angelic', 'playlistId': 'PLiK4FwdJe_H90Nar8uEn5OLr9fqO11dph', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/1TJqJ_VwTu--dyOyEuJ_8HBSeVkgILQ2-RwypsdzRTJM0DRHpW2R3Bo54SVQ01M6SQecCf13yQ=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/1TJqJ_VwTu--dyOyEuJ_8HBSeVkgILQ2-RwypsdzRTJM0DRHpW2R3Bo54SVQ01M6SQecCf13yQ=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 3 tracks', 'count': '3', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Beach Grooves', 'playlistId': 'PLiK4FwdJe_H8yQmgtKWlGnTc1A-nB8BtJ', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/_qWuP8dzJfZ65hsqEVQALSBfZl2kv3gqUODcnZuHoggDlwdzmrvzccd0CtbvItI1dV4qDp_ZSEA=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/_qWuP8dzJfZ65hsqEVQALSBfZl2kv3gqUODcnZuHoggDlwdzmrvzccd0CtbvItI1dV4qDp_ZSEA=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 2 tracks', 'count': '2', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Blues and Jazz', 'playlistId': 'PLiK4FwdJe_H_QMLgArYFiykr_SsbDf8eh', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/b0jdwdPDSiV2gEimz8WGJ_BGOysi6WedUWRaEFavSysCO8NWPOA6w15YDYJ2RQz1ELxQdtt4_CV7rUeQ=w226-h226-l90-rj', 'width': 226, 'height': 226}, {'url': 'https://lh3.googleusercontent.com/b0jdwdPDSiV2gEimz8WGJ_BGOysi6WedUWRaEFavSysCO8NWPOA6w15YDYJ2RQz1ELxQdtt4_CV7rUeQ=w544-h544-l90-rj', 'width': 544, 'height': 544}], 'description': 'Amocles • 1 track', 'count': '1', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Chill Grooves', 'playlistId': 'PLiK4FwdJe_H9RbK5bHDxUbrs7IiFWGnfc', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/fJCv7UtBsDsGqB2OsftrDS_1DyqZxozWCn-r0sXNU_VzHbzbV4qFe35SqsnMlXe8XFJw2VyXV3E=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/fJCv7UtBsDsGqB2OsftrDS_1DyqZxozWCn-r0sXNU_VzHbzbV4qFe35SqsnMlXe8XFJw2VyXV3E=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 8 tracks', 'count': '8', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Combat - Aggressive', 'playlistId': 'PLiK4FwdJe_H8DMMh8aMN_FEmn7vgyzy7l', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/lym5ybbn1QBMxivvyXlvK3ASOG6xy-BxFIBnaeSvy_jOQL6MvJdnA2yUpwjO8z6uJDsfv5hftUIh=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/lym5ybbn1QBMxivvyXlvK3ASOG6xy-BxFIBnaeSvy_jOQL6MvJdnA2yUpwjO8z6uJDsfv5hftUIh=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 16 tracks', 'count': '16', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Combat - Flying', 'playlistId': 'PLiK4FwdJe_H-_j-CUXAFpn8S47DMvXnTz', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/qoUzwujtqG_Otvbsnngd1HiLhsYQuVyheSuIGsJ_f1KEzWdrL9EpfngJ2e_EXuZoSzZyWxzoSXE=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/qoUzwujtqG_Otvbsnngd1HiLhsYQuVyheSuIGsJ_f1KEzWdrL9EpfngJ2e_EXuZoSzZyWxzoSXE=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 3 tracks', 'count': '3', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Combat - Medieval', 'playlistId': 'PLiK4FwdJe_H9s6h_qsL4AjzQZcIm_y3PJ', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/0GlyhuPIIC0rXnnsgB6Ctu6HhqCJ-NmkGHx3wLbefm3E8uJ_Nh_mvyBnc-0ALDJlsgKOwqlrNRc=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/0GlyhuPIIC0rXnnsgB6Ctu6HhqCJ-NmkGHx3wLbefm3E8uJ_Nh_mvyBnc-0ALDJlsgKOwqlrNRc=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 24 tracks', 'count': '24', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Combat - Space', 'playlistId': 'PLiK4FwdJe_H-dSBIrcliD3f0xWczWird7', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/YPLnvTddQTt5Be-tNaWz-A8Une_IekpIUA8vyqkbD7Taf10oU2hNLV2ooZ_o2Aj_0oexnMh67A=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/YPLnvTddQTt5Be-tNaWz-A8Une_IekpIUA8vyqkbD7Taf10oU2hNLV2ooZ_o2Aj_0oexnMh67A=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 3 tracks', 'count': '3', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Covers', 'playlistId': 'PLiK4FwdJe_H-wLb_BhRXzXwiA0ZN5YGvJ', 'thumbnails': [{'url': 'https://lh3.googleusercontent.com/CGGdf87UGlV3noZG3umuALLO9xZmQ1d6mTi1VXLR0Njafo7xIU_jhlIIDyD-FHbuahgy6i4hGZzIZRoE=w226-h226-l90-rj', 'width': 226, 'height': 226}, {'url': 'https://lh3.googleusercontent.com/CGGdf87UGlV3noZG3umuALLO9xZmQ1d6mTi1VXLR0Njafo7xIU_jhlIIDyD-FHbuahgy6i4hGZzIZRoE=w544-h544-l90-rj', 'width': 544, 'height': 544}], 'description': 'Amocles • 1 track', 'count': '1', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': 'Electronic - Dance', 'playlistId': 'PLiK4FwdJe_H8lnvJOmZtK11PUijABnS4', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/tiE7RgMfOwebYOubSQD9ec0Ct-Z0NdhCeb4a834TMYUwLIFh6zyFAziVeFhENRSr8Kh8d7zr-hA=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/tiE7RgMfOwebYOubSQD9ec0Ct-Z0NdhCeb4a834TMYUwLIFh6zyFAziVeFhENRSr8Kh8d7zr-hA=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 30 tracks', 'count': '30', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}, {'title': '_Electronic - Jazz and House', 'playlistId': 'PLiK4FwdJe_H8371HDffspLhpAcC1ThBnL', 'thumbnails': [{'url': 'https://yt3.googleusercontent.com/SV264D3n7uKiZQhyPYVFfD8Cze34QYaIc77YK_ZoF6pzhGcNGVLgsSC74gWYH87X8QKP7HVwGA=s192', 'width': 192, 'height': 192}, {'url': 'https://yt3.googleusercontent.com/SV264D3n7uKiZQhyPYVFfD8Cze34QYaIc77YK_ZoF6pzhGcNGVLgsSC74gWYH87X8QKP7HVwGA=s576', 'width': 576, 'height': 576}], 'description': 'Amocles • 8 tracks', 'count': '8', 'author': [{'name': 'Amocles', 'id': 'UC5wNnpbyoKFKgLgvDFw6FYg'}]}]

I encapsulated the data model in another class. I tried adding - to no avail - a parent data element at the beginning of the json file:

{"playlistList":[{

still got the error


Solution

  • The error is pretty explanatory. To fix it you should replace all single quotes with double quotes in your json file.

    TIP: there is a number of online json validators that you can use to check if your file is a valid json file.