import json


def call_jsonrpc(client, query):
    """
    Send query and return the response.

    Parameters
    ----------
    client: client fixture
    query: dict
        The query string to POST to the server
        in decoded JSON format.
    Return
    ------
    any
        The JSON decoded value of the response.
    """
    if isinstance(query, dict):
        query = json.dumps(query)

    headers = {"Content-Type": "application/json"}
    rv = client.post('/api', data=query, headers=headers)
    assert rv.status_code == 200
    response_object = json.loads(rv.data)
    return response_object