Minify JSON

    Args:
        src: json string or path-to-file with text to minify (mandatory)
        dest: path-to-file to save minified xml string; (optional)
              - if file doesn't exist it is created automatically;
              - if this arg is skept function returns string

    Returns: 1) minified JSON string if dest is not provided
             2) length of saved file if dest is provided

    Example:
            json.min('path/to/file.json')
            json.min('path/to/file.json', 'path/to/save/result.json')

def _json_min(src, dest=''):
    """Minify JSON

    Args:
        src: json string or path-to-file with text to minify (mandatory)
        dest: path-to-file to save minified xml string; (optional)
              - if file doesn't exist it is created automatically;
              - if this arg is skept function returns string

    Returns: 1) minified JSON string if dest is not provided
             2) length of saved file if dest is provided

    Example:
            json.min('path/to/file.json')
            json.min('path/to/file.json', 'path/to/save/result.json')
    """

    if dest == '':
        return _json_min_exec(_text(src)) # returns string
    else:
        if type(dest) is bool:  # dest is skept, custom pattern provided at dist place
            return _json_min_exec(_text(src), dest)
        else:
            with open(dest, 'w') as f2:
                return f2.write(_json_min_exec(_text(src)))