Skip to main content

PyJsonX data visualization of regression, classification and distribution

Project description

PyJsonX

Switch to Japanese: 日本語

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:

pip3 install PyJsonX
pip3 install git+https://github.com/nnnnnnn0090/PyJsonX

File Extension

Usage

Embedding Python in JSON

You can embed Python code within JSON using <?py ... ?> tags. Here’s an example: スクリーンショット 2024-08-18 5 57 43

{
    "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:

    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:

    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. (Coming Soon)

Contributing

Contributions are welcome! Please submit a pull request or open an issue on our GitHub repository.

License

PyJsonX is licensed under the MIT License. See LICENSE for details.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjsonx-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file pyjsonx-0.0.2.tar.gz.

File metadata

  • Download URL: pyjsonx-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pyjsonx-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c0c3377a6d70cf084ff432c979ff729a944f14ccf25d66d255bdb371a902658d
MD5 ea158f572d7754c9b08614c3215130a4
BLAKE2b-256 6e6fb90c0859b12f5cf06e6e47a8614b687594a82ad42f88e12e01f45392dd04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page