Skip to content

pyx-industries/json-excel-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“˜ JSON ↔ Excel Mapping Tool

This project converts between JSON Schema, JSON Instances, and Excel mappings.
It supports three modes:

  1. Schema β†’ Excel: Generate an Excel mapping from a JSON Schema.
  2. Instance β†’ Excel: Flatten a JSON instance into an Excel mapping.
  3. Excel β†’ Instance: Reconstruct a JSON instance from an Excel mapping.

πŸ“‚ Folder Structure

json-schema-mapper/
β”œβ”€β”€ files/input/   # put your JSON Schemas here
β”œβ”€β”€ files/output/  # Excel mapping will be saved here
β”œβ”€β”€ src/           # main Python code
└── run.py         # entrypoint

πŸš€ Setup & Usage

  1. Create and activate a Python virtual environment (recommended):

    python -m venv .venv
    source .venv/bin/activate   # Linux / macOS
    .venv\Scripts\activate      # Windows
  2. Install dependencies:

    pip install -r requirements.txt
  3. Place your files in files/input/, e.g.:

    files/input/0.6.0/FacilityRecord.json                # schema
    files/input/0.6.0/sample_instance/FacilityRecord_instance.json   # instance
    files/input/0.6.0/sample_instance_excel/FacilityRecord_instance_mapping.xlsx  # excel
    
  4. Run the tool:

    python run.py
  5. Choose a mode when prompted:

    Choose an action:
    1 - Convert JSON schema(s) to Excel
    2 - Convert JSON instance(s) to Excel
    3 - Convert Excel(s) to JSON instance(s)
    
  6. Enter the input file or folder path and the output folder path (defaults are provided):

    Enter input file or folder path [files/input]:
    Enter output folder path [files/output]:
    

πŸ“‚ Input & Output Examples

  • Schema β†’ Excel

    files/input/0.6.0/FacilityRecord.json
    β†’ files/output/0.6.0/FacilityRecord_mapping.xlsx
    
  • Instance β†’ Excel

    files/input/0.6.0/sample_instance/FacilityRecord_instance.json
    β†’ files/output/0.6.0/sample_instance/FacilityRecord_instance_mapping.xlsx
    
  • Excel β†’ Instance

    files/output/0.6.0/sample_instance/FacilityRecord_instance_mapping.xlsx
    β†’ files/output/0.6.0/sample_instance_json/FacilityRecord_instance_mapping_instance.json
    

βœ… Notes

πŸ“ Excel Columns for JSON Instance

  • Path β†’ flattened JSON path (e.g., root.child[0].name)
  • Type β†’ data type (string, int, float, bool, array, dict)
  • Value β†’ actual value or JSON-encoded list/dict

πŸ“ Excel Columns for JSON Schema

  • Path β†’ JSON path to the field
  • Type β†’ field type (string, number, object, array, ref)
  • Required β†’ whether the field is mandatory
  • Description β†’ schema description
  • Ref β†’ $ref target if applicable
  • Writable β†’ whether you can directly enter a value
  • Value β†’ pre-filled with schema defaults if provided

About

This python script maps a JSON schema to an excel workbook for easier data mapping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages