generated from Hazel/python-project
Compare commits
No commits in common. "96bb1fce8ec4f97cd2221c33025450c3625fc36a" and "4f252a83cc18f8c7ef572e5ccbf83da0bcaa2bd9" have entirely different histories.
96bb1fce8e
...
4f252a83cc
19
README.md
19
README.md
@ -1,22 +1,3 @@
|
||||
# Json-Unescape
|
||||
|
||||
Unescape json string, which is escaped for json. This is usually necessarry for webscraping.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install json-unescape
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```python
|
||||
>>> from json_unescape import escape_json, unescape_json
|
||||
|
||||
>>> escape_json('{"foo": "bar,,,eee"}')
|
||||
'{"key": "{\\"foo\\": \\"bar,,,eee\\"}"}'
|
||||
|
||||
>>> unescape_json(escape_json('{"key": "{\\"foo\\": \\"bar,,,eee\\"}"}'))
|
||||
'{"foo": "bar,,,eee"}'
|
||||
```
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
import json
|
||||
|
||||
|
||||
def escape_json(json_str: str) -> str:
|
||||
nested_object: dict = {"key": json_str}
|
||||
return json.dumps(nested_object)
|
||||
|
||||
def unescape_json(json_str: str) -> str:
|
||||
nested_json_string: str = '{"key": ' + json_str + '}'
|
||||
return json.loads(nested_json_string)["key"]
|
5
json_unescape/__main__.py
Normal file
5
json_unescape/__main__.py
Normal file
@ -0,0 +1,5 @@
|
||||
from .__about__ import __name__, __version__
|
||||
|
||||
|
||||
def cli():
|
||||
print(f"Running {__name__} version {__version__} from __main__.py")
|
@ -12,6 +12,9 @@ classifiers = [
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
json-unescape = "json_unescape.__main__:cli"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling", "hatch-requirements-txt"]
|
||||
build-backend = "hatchling.build"
|
||||
|
Loading…
Reference in New Issue
Block a user