[GH-ISSUE #791] Valid json uses " for strings, not ' #492

Closed
opened 2026-02-27 23:22:55 +03:00 by kerem · 2 comments
Owner

Originally created by @Ximzend on GitHub (Mar 12, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/791

I tried several online json beatify pages to explorer the json I got from spotipy and they all gave an error. The issue: spotipy uses ' instead of " for strings.

Originally created by @Ximzend on GitHub (Mar 12, 2022). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/791 I tried several online json beatify pages to explorer the json I got from spotipy and they all gave an error. The issue: spotipy uses ' instead of " for strings.
kerem 2026-02-27 23:22:55 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (Nov 15, 2022):

If you mean the "JSON" you get when you call a search function for example, then this is not JSON. This is already parsed into a python object. Python automatically displays strings with a ', even if you create the string with a ". So just do this if you want to get a JSON string:

import json
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="YOUR_APP_CLIENT_ID",
                                                           client_secret="YOUR_APP_CLIENT_SECRET"))

result = sp.search(q='weezer', limit=20)
json_result = json.dumps(result)
print(json_result)
<!-- gh-comment-id:1315234076 --> @dieser-niko commented on GitHub (Nov 15, 2022): If you mean the "JSON" you get when you call a search function for example, then this is not JSON. This is already parsed into a python object. Python automatically displays strings with a `'`, even if you create the string with a `"`. So just do this if you want to get a JSON string: ```python3 import json import spotipy from spotipy.oauth2 import SpotifyClientCredentials sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="YOUR_APP_CLIENT_ID", client_secret="YOUR_APP_CLIENT_SECRET")) result = sp.search(q='weezer', limit=20) json_result = json.dumps(result) print(json_result) ```
Author
Owner

@dieser-niko commented on GitHub (May 1, 2024):

Closing as there's no activity

<!-- gh-comment-id:2087882047 --> @dieser-niko commented on GitHub (May 1, 2024): Closing as there's no activity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#492
No description provided.