Download augmentoolkit/utils/escape_string_for_json.py from Leon4gr45/agent-0: direct link, hf CLI and curl.
- Browser
- Download file 327 Bytes
-
https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/escape_string_for_json.py
- Command line
-
hf download hf://spaces/Leon4gr45/agent-0/augmentoolkit/utils/escape_string_for_json.py
-
curl -L -o escape_string_for_json.py https://huggingface.co/spaces/Leon4gr45/agent-0/resolve/main/augmentoolkit/utils/escape_string_for_json.py
327 Bytes
| import json | |
| def escape_string_for_json(string: str) -> str: | |
| escaped_string = json.dumps(string) | |
| return escaped_string[1:-1] | |
| # Test the function | |
| if __name__ == "__main__": | |
| test_str = 'This is a "test" [string] {} with some \\"escaped\\" quotes and "unescaped" ones.' | |
| print(escape_string_for_json(test_str)) | |