Skip to content

About

Command-line JSON data manager in Python: create, view, edit, and save data using the json module.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

JSON Data Manager

A command-line Python tool for creating, viewing, and editing data stored in a JSON file. It loads a JSON file into a Python dictionary, lets you add, update, or delete entries from a menu, and saves the changes back to disk.

Features

  • Save starter data: create data.json with a starter profile (asks before overwriting)
  • Load data: read the file and show which keys it contains
  • View data: print the full contents, neatly formatted
  • Add or update: add a new key and value, or change an existing one
  • Delete data: remove a key and its value
  • Starts safely on a first run, even if data.json doesn't exist yet

Requirements

  • Python 3.6 or newer
  • No external packages; it uses only Python's built-in json module

Getting Started

  1. Clone the repository:

    git clone https://github.com/MichaelTM0/json-data-manager.git
    cd json-data-manager
  2. Run the program:

    python jsondata.py
  3. Choose option 1 to create data.json with the starter data, or option 4 to start adding your own.

Usage

==================================================
1. Save starter data (overwrites file)
2. Load data
3. View data
4. Add or update data
5. Delete data
6. Exit
Please enter a number (1-6):

Example output for option 3 (View data):

{
    "name": "Michael",
    "age": 26,
    "skills": [
        "Python",
        "AWS",
        "GitHub"
    ]
}

How It Works

Every change follows the same three steps:

  1. Load: load_data() opens data.json and uses json.load to turn it into a Python dictionary.
  2. Change: the dictionary is edited in Python (adding, updating, or deleting a key).
  3. Save: save_data() uses json.dump to write the updated dictionary back to data.json.

The file is only open while it's being read or written. All edits happen on the dictionary in memory, and with blocks close the file automatically.

Future Improvements

  • Convert number input to integers (right now, everything typed is saved as text)
  • Add items to list values, like adding a new skill to skills
  • Support multiple profiles instead of one
  • Back up the file before overwriting it

What I Learned

  • Reading and writing JSON files with json.load and json.dump
  • How Python dictionaries map to JSON
  • Writing reusable load_data and save_data helpers instead of repeating file code
  • Using with blocks so files close automatically
  • When to use try/except (unexpected errors) vs if/else (expected choices)

Author

Michael Murchie

About

Command-line JSON data manager in Python: create, view, edit, and save data using the json module.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages