Skip to content

A modern Android app for parsing, filtering, and converting NDJSON files. Built with Jetpack Compose, Material Design 3, and MVVM architecture.

License

Notifications You must be signed in to change notification settings

Syedovaiss/NDJson-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ NDJSON Parser

Android Kotlin Jetpack Compose Material Design 3

A modern Android application for parsing, filtering, and converting NDJSON (Newline Delimited JSON) files with a beautiful Material Design 3 UI.

Features β€’ Architecture β€’ Tech Stack β€’ Installation β€’ Usage


✨ Features

πŸ” Core Functionality

  • πŸ“‚ File Selection: Easy file picker to select NDJSON files from your device
  • πŸ”Ž Smart Filtering: Filter JSON objects by key and value with case-insensitive matching
  • πŸ”„ Format Conversion:
    • Convert NDJSON to standard JSON array format
    • Convert NDJSON to CSV format with proper escaping
  • πŸ’Ύ File Download: Download converted files directly to your device's Downloads folder
  • πŸ“Š Data Visualization: Beautiful card-based UI to view parsed JSON data

🎨 User Experience

  • Modern Material Design 3: Beautiful, intuitive interface with dynamic colors
  • Real-time Filtering: Instant results as you type
  • Error Handling: Comprehensive error messages with line-by-line parsing feedback
  • Loading States: Visual feedback during file operations
  • Accessibility: Full support for content descriptions and screen readers

πŸ—οΈ Architecture

This project follows Clean Architecture principles with MVVM pattern and SOLID principles:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Presentation Layer                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚   UI/Compose β”‚  β”‚  ViewModel   β”‚  β”‚  UI State    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Domain Layer                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Use Cases   β”‚  β”‚  Repository  β”‚  β”‚   Models     β”‚   β”‚
β”‚  β”‚              β”‚  β”‚  Interface   β”‚  β”‚              β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Data Layer                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚
β”‚  β”‚  Repository   β”‚  β”‚  Data Source β”‚                    β”‚
β”‚  β”‚ Implementationβ”‚  β”‚              β”‚                    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Layer Responsibilities

Presentation Layer

  • UI Components: Reusable Compose components
  • ViewModel: Manages UI state and business logic
  • UI State: Immutable state objects

Domain Layer

  • Use Cases: Single responsibility business logic operations
    • ParseNDJsonUseCase: Parse NDJSON files
    • ConvertToJsonUseCase: Convert to JSON format
    • ConvertToCsvUseCase: Convert to CSV format
    • FilterByKeyUseCase: Filter by key/value
    • DownloadFileUseCase: Download converted files
  • Repository Interface: Abstraction for data operations
  • Models: Domain entities

Data Layer

  • Repository Implementation: Concrete implementation of repository
  • File Operations: Reading and writing files

🎯 SOLID Principles

  • βœ… Single Responsibility: Each use case has one clear purpose
  • βœ… Open/Closed: Extensible through interfaces
  • βœ… Liskov Substitution: Repository implementations are interchangeable
  • βœ… Interface Segregation: Focused, minimal interfaces
  • βœ… Dependency Inversion: Depend on abstractions, not concretions

πŸ› οΈ Tech Stack

Core Technologies

  • Language: Kotlin 2.0.21
  • UI Framework: Jetpack Compose with Material Design 3
  • Architecture: MVVM (Model-View-ViewModel)
  • Async Operations: Kotlin Coroutines & Flow
  • JSON Parsing: Kotlinx Serialization

Libraries & Dependencies

// Core Android
- androidx.core:core-ktx
- androidx.lifecycle:lifecycle-runtime-ktx
- androidx.activity:activity-compose

// Compose
- androidx.compose.ui
- androidx.compose.material3
- androidx.compose.ui.tooling

// Architecture
- androidx.lifecycle:lifecycle-viewmodel-compose
- androidx.lifecycle:lifecycle-runtime-compose

// Coroutines
- kotlinx-coroutines-android

// Serialization
- kotlinx-serialization-json

Build Tools

  • Gradle: 8.13.2
  • Android Gradle Plugin: 8.13.2
  • Kotlin: 2.0.21

πŸš€ Installation

Prerequisites

  • Android Studio Hedgehog or later
  • JDK 11 or higher
  • Android SDK (API 24+)
  • Gradle 8.13.2+

Setup Steps

  1. Clone the repository

    git clone https://github.com/yourusername/NDJsonParser.git
    cd NDJsonParser
  2. Open in Android Studio

    • Open Android Studio
    • Select "Open an Existing Project"
    • Navigate to the cloned directory
  3. Sync Gradle

    • Android Studio will automatically sync Gradle
    • Wait for dependencies to download
  4. Build and Run

    • Connect an Android device or start an emulator
    • Click "Run" or press Shift + F10

πŸ“¦ Add to Your Project

Using JitPack

You can add this library to your Android project using JitPack.

Step 1: Add JitPack Repository

Add the JitPack repository to your settings.gradle.kts (or settings.gradle):

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Step 2: Add Dependency

Add the dependency to your app/build.gradle.kts (or app/build.gradle):

dependencies {
    implementation("com.github.Syedovaiss:NDJson-Parser:1.0.1")
}

Step 3: Sync Project

  • Sync your Gradle files
  • The library will be downloaded and added to your project

πŸ“– Usage

1. Select a File

  • Tap the "Select NDJSON File" button
  • Choose an NDJSON file from your device
  • The app will automatically parse the file

2. View Data

  • Parsed JSON objects are displayed in beautiful cards
  • Each card shows:
    • Item number
    • Number of fields
    • Formatted JSON content

3. Filter Data

  • Enter a key name (e.g., "name", "id", "email")
  • Optionally enter a value to filter by
  • Tap "Apply Filter" to see filtered results
  • Tap "Clear" to remove the filter

4. Convert & Download

  • Tap "JSON" to download as JSON array format
  • Tap "CSV" to download as CSV format
  • Files are saved to Downloads/NDJsonParser/

Example NDJSON File

{"name":"John Doe","age":30,"city":"New York"}
{"name":"Jane Smith","age":25,"city":"Los Angeles"}
{"name":"Bob Johnson","age":35,"city":"Chicago"}

πŸ“ Project Structure

app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/com/ovais/ndjsonparser/
β”‚   β”‚   β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”‚   β”‚   └── repository/
β”‚   β”‚   β”‚   β”‚       └── NDJsonRepositoryImpl.kt
β”‚   β”‚   β”‚   β”œβ”€β”€ di/
β”‚   β”‚   β”‚   β”‚   └── AppModule.kt
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ model/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ FileFormat.kt
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ JsonObject.kt
β”‚   β”‚   β”‚   β”‚   β”‚   └── ParseResult.kt
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ repository/
β”‚   β”‚   β”‚   β”‚   β”‚   └── NDJsonRepository.kt
β”‚   β”‚   β”‚   β”‚   └── usecase/
β”‚   β”‚   β”‚   β”‚       β”œβ”€β”€ ConvertToCsvUseCase.kt
β”‚   β”‚   β”‚   β”‚       β”œβ”€β”€ ConvertToJsonUseCase.kt
β”‚   β”‚   β”‚   β”‚       β”œβ”€β”€ DownloadFileUseCase.kt
β”‚   β”‚   β”‚   β”‚       β”œβ”€β”€ FilterByKeyUseCase.kt
β”‚   β”‚   β”‚   β”‚       └── ParseNDJsonUseCase.kt
β”‚   β”‚   β”‚   β”œβ”€β”€ presentation/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ DataDisplay.kt
β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ DownloadButtons.kt
β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ FilePickerButton.kt
β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   └── FilterSection.kt
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ screen/
β”‚   β”‚   β”‚   β”‚   β”‚   β”‚   └── NDJsonParserScreen.kt
β”‚   β”‚   β”‚   β”‚   β”‚   └── state/
β”‚   β”‚   β”‚   β”‚   β”‚       └── NDJsonUiState.kt
β”‚   β”‚   β”‚   β”‚   └── viewmodel/
β”‚   β”‚   β”‚   β”‚       └── NDJsonViewModel.kt
β”‚   β”‚   β”‚   └── MainActivity.kt
β”‚   β”‚   └── res/
β”‚   β”‚       β”œβ”€β”€ values/
β”‚   β”‚       β”‚   └── strings.xml
β”‚   β”‚       └── ...
β”‚   └── test/
└── build.gradle.kts

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Commit your changes
    git commit -m "Add some amazing feature"
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

Code Style

  • Follow Kotlin coding conventions
  • Use meaningful variable and function names
  • Add comments for complex logic
  • Write unit tests for new features

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2024 Syed Ovais Akhtar


πŸ‘€ Author

Syed Ovais Akhtar


πŸ™ Acknowledgments


Made with ❀️ using Kotlin and Jetpack Compose

⭐ Star this repo if you find it helpful!

About

A modern Android app for parsing, filtering, and converting NDJSON files. Built with Jetpack Compose, Material Design 3, and MVVM architecture.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages