import json


def get_json(timestamp,location,cameraID,warningType,info=None):
    """
    产生json数据
    Args:
        timestamp:时间戳
        location:摄像头位置
        cameraID:摄像头唯一标识号ID
        warningType:{0:无异常
                     1:黑名单人
                     2:未知人
                     3:外来车
                     4:碰撞
                     5:火情（红外）}
        info:额外备注信息，默认为空
    Returns:
        返回json格式数据
        示例：
        {"time": 1576324177, "location": 1, "cameraID": 3, "warningType": 3, "info": "fakenews"}
    """
    data=dict()

    data['time']=timestamp
    data['location']=location
    data['cameraID']=cameraID
    warninglist=["No-Waring","BlackList","UnknowPerson","UnknowCar","CarCrash","Fire"]
    warning={'warningType':warningType,'warningEvnet':warninglist[warningType]}
    data['warning']=warning
    data['info']=info

    myjson=json.dumps(data)
    return myjson