import requests
import json


def get_assoc_comments(subm_id):
    """ For a submission ID, request a JSON of associated comments."""
    cs_page = requests.get(
        "https://api.pushshift.io/reddit/search/comment/?link_id={}".format(subm_id)
    )
    try:
        comments = json.loads(cs_page.text)["data"]
    except ValueError:
        comments = [] # Trying to decode from None (JSONDecodeError)
    return comments