| Name | PyJsonX JSON |
| Version |
0.0.2
JSON |
| download |
| home_page | https://github.com/nnnnnnn0090/PyJsonX |
| Summary | PyJsonX data visualization of regression, classification and distribution |
| upload_time | 2024-08-18 10:24:44 |
| maintainer | nnnnnnn0090 |
| docs_url | None |
| author | nnnnnnn0090 |
| requires_python | >=3.0 |
| license | MIT |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# PyJsonX
[Switch to Japanese: 日本語](https://github.com/nnnnnnn0090/PyJsonX/blob/main/README.ja.md)
### Overview
`PyJsonX` is a Python library inspired by PHP's capability to embed code within templates. It allows you to embed Python code within JSON files, facilitating the generation of dynamic and programmable JSON content. This library provides a way to create flexible JSON structures directly from within Python, similar to how PHP allows embedding code within HTML.
### Installation
You can install `PyJsonX` using pip:
```bash
pip3 install PyJsonX
pip3 install git+https://github.com/nnnnnnn0090/PyJsonX
```
### File Extension
- `PyJsonX` uses the `.pyjsonX` extension. [example.pyjsonX](https://github.com/nnnnnnn0090/PyJsonX/blob/main/PyJsonX/example.pyjsonX)
VSCode has an extension for `.pyjsonX` files. [VisualStudio MarketPlace](https://marketplace.visualstudio.com/items?itemName=nnnnnnn0090.pyjsonX)
### Usage
#### Embedding Python in JSON
You can embed Python code within JSON using `<?py ... ?>` tags. Here’s an example:
<img width="558" alt="スクリーンショット 2024-08-18 5 57 43" src="https://github.com/user-attachments/assets/4764041b-6ce4-42c7-adb0-257b699284d4">
↓
```json
{
"static_field": "value",
"dynamic_0": "0",
"dynamic_1": "2",
"dynamic_2": "4",
"dynamic_3": "6",
"dynamic_4": "8",
"another_static_field": "another_value"
}
```
#### Executing Embedded Python
1. **From JSON String:**
```python
import PyJsonX
json_str = '''
{
"static_field": "value",
<?py
result = ""
# Generate dynamic fields with values from 0 to 4
for i in range(5):
result += f'"dynamic_{i}": "{i * 2}", \n'
return result
?>
"another_static_field": "another_value"
}
'''
# Process the JSON string and execute the embedded Python code
processed_str = PyJsonX.execute(json_str)
print(processed_str) # Output the processed JSON
```
2. **From JSON Files:**
```python
import PyJsonX
input_json_path = 'input.json' # Path to the input JSON file
output_json_path = 'output.json' # Path to the output JSON file
# Process the JSON file and execute the embedded Python code
PyJsonX.execute_file(input_json_path, output_json_path)
```
### Features
- **Dynamic Content Generation:** Embed and execute Python code directly within JSON to generate dynamic content.
- **Flexible Data Creation:** Generate complex JSON structures dynamically based on programmatic logic.
- **Inspired by PHP:** Draws inspiration from PHP's templating capabilities, allowing for similar embedded code functionality within JSON.
### Documentation
For more detailed information, visit the [PyJsonX Documentation](https://github.com/nnnnnnn0090/PyJsonX). (Coming Soon)
### Contributing
Contributions are welcome! Please submit a pull request or open an issue on our [GitHub repository](https://github.com/nnnnnnn0090/PyJsonX).
### License
`PyJsonX` is licensed under the MIT License. See [LICENSE](https://github.com/nnnnnnn0090/PyJsonX/blob/main/LICENSE) for details.
---
Raw data
{
"_id": null,
"home_page": "https://github.com/nnnnnnn0090/PyJsonX",
"name": "PyJsonX",
"maintainer": "nnnnnnn0090",
"docs_url": null,
"requires_python": ">=3.0",
"maintainer_email": "nnnnnnn0090@gmail.com",
"keywords": null,
"author": "nnnnnnn0090",
"author_email": "nnnnnnn0090@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6e/6f/b90c0859b12f5cf06e6e47a8614b687594a82ad42f88e12e01f45392dd04/pyjsonx-0.0.2.tar.gz",
"platform": null,
"description": "# PyJsonX\n\n[Switch to Japanese: \u65e5\u672c\u8a9e](https://github.com/nnnnnnn0090/PyJsonX/blob/main/README.ja.md)\n\n### Overview\n\n`PyJsonX` is a Python library inspired by PHP's capability to embed code within templates. It allows you to embed Python code within JSON files, facilitating the generation of dynamic and programmable JSON content. This library provides a way to create flexible JSON structures directly from within Python, similar to how PHP allows embedding code within HTML.\n\n### Installation\n\nYou can install `PyJsonX` using pip:\n\n```bash\npip3 install PyJsonX\npip3 install git+https://github.com/nnnnnnn0090/PyJsonX\n```\n\n### File Extension\n\n- `PyJsonX` uses the `.pyjsonX` extension. [example.pyjsonX](https://github.com/nnnnnnn0090/PyJsonX/blob/main/PyJsonX/example.pyjsonX) \n VSCode has an extension for `.pyjsonX` files. [VisualStudio MarketPlace](https://marketplace.visualstudio.com/items?itemName=nnnnnnn0090.pyjsonX)\n\n### Usage\n\n#### Embedding Python in JSON\n\nYou can embed Python code within JSON using `<?py ... ?>` tags. Here\u2019s an example:\n<img width=\"558\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2024-08-18 5 57 43\" src=\"https://github.com/user-attachments/assets/4764041b-6ce4-42c7-adb0-257b699284d4\">\n\n\u2193\n```json\n{\n \"static_field\": \"value\",\n \"dynamic_0\": \"0\",\n \"dynamic_1\": \"2\",\n \"dynamic_2\": \"4\",\n \"dynamic_3\": \"6\",\n \"dynamic_4\": \"8\",\n \"another_static_field\": \"another_value\"\n}\n```\n\n#### Executing Embedded Python\n\n1. **From JSON String:**\n\n ```python\n import PyJsonX\n\n json_str = '''\n {\n \"static_field\": \"value\",\n <?py\n result = \"\"\n # Generate dynamic fields with values from 0 to 4\n for i in range(5):\n result += f'\"dynamic_{i}\": \"{i * 2}\", \\n'\n return result\n ?>\n \"another_static_field\": \"another_value\"\n }\n '''\n\n # Process the JSON string and execute the embedded Python code\n processed_str = PyJsonX.execute(json_str)\n print(processed_str) # Output the processed JSON\n ```\n\n2. **From JSON Files:**\n\n ```python\n import PyJsonX\n\n input_json_path = 'input.json' # Path to the input JSON file\n output_json_path = 'output.json' # Path to the output JSON file\n\n # Process the JSON file and execute the embedded Python code\n PyJsonX.execute_file(input_json_path, output_json_path)\n ```\n\n### Features\n\n- **Dynamic Content Generation:** Embed and execute Python code directly within JSON to generate dynamic content.\n- **Flexible Data Creation:** Generate complex JSON structures dynamically based on programmatic logic.\n- **Inspired by PHP:** Draws inspiration from PHP's templating capabilities, allowing for similar embedded code functionality within JSON.\n\n### Documentation\n\nFor more detailed information, visit the [PyJsonX Documentation](https://github.com/nnnnnnn0090/PyJsonX). (Coming Soon)\n\n### Contributing\n\nContributions are welcome! Please submit a pull request or open an issue on our [GitHub repository](https://github.com/nnnnnnn0090/PyJsonX).\n\n### License\n\n`PyJsonX` is licensed under the MIT License. See [LICENSE](https://github.com/nnnnnnn0090/PyJsonX/blob/main/LICENSE) for details.\n\n---\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "PyJsonX data visualization of regression, classification and distribution",
"version": "0.0.2",
"project_urls": {
"Download": "https://github.com/nnnnnnn0090/PyJsonX",
"Homepage": "https://github.com/nnnnnnn0090/PyJsonX"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6e6fb90c0859b12f5cf06e6e47a8614b687594a82ad42f88e12e01f45392dd04",
"md5": "ea158f572d7754c9b08614c3215130a4",
"sha256": "c0c3377a6d70cf084ff432c979ff729a944f14ccf25d66d255bdb371a902658d"
},
"downloads": -1,
"filename": "pyjsonx-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "ea158f572d7754c9b08614c3215130a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.0",
"size": 4430,
"upload_time": "2024-08-18T10:24:44",
"upload_time_iso_8601": "2024-08-18T10:24:44.322782Z",
"url": "https://files.pythonhosted.org/packages/6e/6f/b90c0859b12f5cf06e6e47a8614b687594a82ad42f88e12e01f45392dd04/pyjsonx-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-18 10:24:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nnnnnnn0090",
"github_project": "PyJsonX",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyjsonx"
}