A Java CLI application to add, view, and update user records, persisted locally in a JSON file using the Jackson library.
- Java JDK 8 or higher
- Maven (to resolve dependencies)
No additional setup needed — data is stored locally in a JSON file.
- Clone the repository
- Add Jackson Databind to your
pom.xml:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
</dependency>- Run
Main.javaand follow the prompts
- Add a new user (ID, name, age, occupation, language)
- Look up a user by ID
- Update fields of an existing user (skip any field to leave it unchanged)
- Persists data to
src/main/java/database.jsonautomatically - Handles missing database file by creating it on first run
- Safely handles lookups for non-existent IDs
- Zero external database setup — just a flat JSON file
- Human-readable storage, easy to inspect or edit manually
TreeMapkeeps records sorted by ID automatically- Lightweight with minimal dependencies
- Runs on any device with Java and Maven installed
- No delete — there is no way to remove a user
- No input validation — entering a string where an integer is expected will crash
- No duplicate ID check — adding a user with an existing ID silently overwrites it
- Not thread-safe — concurrent access would corrupt the JSON file
- Flat schema — the
UserRecordmodel is rigid; adding new fields requires code changes - Hardcoded file path — database location is fixed to
src/main/java/database.json
- Add a delete-by-ID option
- Validate input types before parsing (especially
age) - Check for ID conflicts before inserting and prompt accordingly
- Add search by name instead of just ID
- Make the database file path configurable
- Replace the flat JSON file with SQLite for more robust storage as the project grows