import json


def _dump_json_command(command, sender_client_id, sender, recipient_client_id, recipient, round_table, last_client,
                       round_restriction):
    """
    Dump json command as text.
    :param command: text representing the command.
    :param sender_client_id: client id of the sender user
    :param sender: sender name
    :param recipient_client_id: id of the recipient client or '' for all
    :param recipient: recipient name or '' for all
    :param round_table: True iff the sender thinks it is the round table moderator at sending.
    :param last_client: Ture, False None: True iff sender client is the last client of the sender user.
    :return: text version of the json-encoded command.
    """
    content = {'user': command, 'round_table': round_table}
    if last_client is not None:
        content['last_client'] = last_client

    json_text = json.dumps({'sender_client_id': sender_client_id, 'sender': sender,
                            'recipient_client_id': recipient_client_id, 'recipient': recipient,
                            'type': 'command', 'content': content})
    return json_text