Skip to content

AndreyBegun/JSON_Database_with_Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗄️ JSON Database (Client-Server Application in Java)

A multithreaded JSON-based key-value database built with Java and Gradle. The project implements client-server communication over sockets, supporting commands like set, get, delete, and exit. In the advanced stages, it supports nested JSON keys and path-based access.

🚀 Features

✅ Lightweight JSON database (stores and retrieves any JSON data)
✅ Nested key access (e.g., ["person","name"])
✅ Multithreaded TCP server
✅ Client-server communication with JSON messages
✅ Supports set, get, delete, and exit commands
✅ Configured as a multi-module Gradle project

📂 Project Structure

JSON_Database_with_Java/

├── common/ → shared JSON utilities & communication logic
├── server/ → TCP server that manages the database
└── client/ → CLI client that sends requests to the server

⚙️ How to Build and Run

🏗 Build the project
./gradlew build

🖥 Start the Server

Run in one terminal:

./gradlew :server:run

Output:

Server started!

💬 Start the Client

In another terminal, run:

./gradlew :client:run --args="-t set -k text -v 'Hello World!'"

Output:

Client started!
Sent: {
"type":"set",
"key":"text",
"value":"Hello World!"
} Received: {"response":"OK"}

🧩 Example JSON Input (via file)

You can also use a .json input file:

./gradlew :client:run --args="-in getFile.json"

🧠 Example Commands

Command Description Example set Store a value -t set -k text -v "Hello World!" get Retrieve a value -t get -k text delete Remove a key -t delete -k text exit Stop the server -t exit 🧬 Nested JSON Example

Set nested object:

./gradlew :client:run --args='-in setPerson.json'

Contents of setPerson.json:

{
"type": "set",
"key": "person",
"value": {
"name": "Elon Musk",
"car": { "model": "Tesla Roadster", "year": "2018" },
"rocket": { "name": "Falcon 9", "launches": "87" }
}
}

Get nested field:

./gradlew :client:run --args='-in getSurname.json'

getSurname.json:

{
"type": "get",
"key": ["person","car","model"]
}

🧰 Technologies Used

Java 17+

Gradle (multi-module build)

Gson (for JSON parsing)

ExecutorService (for concurrency)

🧑‍💻 Author

Andrei Biahun

abiahun@griddynamics.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages