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
- π 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
- 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
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β β β β
β βββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- UI Components: Reusable Compose components
- ViewModel: Manages UI state and business logic
- UI State: Immutable state objects
- Use Cases: Single responsibility business logic operations
ParseNDJsonUseCase: Parse NDJSON filesConvertToJsonUseCase: Convert to JSON formatConvertToCsvUseCase: Convert to CSV formatFilterByKeyUseCase: Filter by key/valueDownloadFileUseCase: Download converted files
- Repository Interface: Abstraction for data operations
- Models: Domain entities
- Repository Implementation: Concrete implementation of repository
- File Operations: Reading and writing files
- β 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
- 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
// 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- Gradle: 8.13.2
- Android Gradle Plugin: 8.13.2
- Kotlin: 2.0.21
- Android Studio Hedgehog or later
- JDK 11 or higher
- Android SDK (API 24+)
- Gradle 8.13.2+
-
Clone the repository
git clone https://github.com/yourusername/NDJsonParser.git cd NDJsonParser -
Open in Android Studio
- Open Android Studio
- Select "Open an Existing Project"
- Navigate to the cloned directory
-
Sync Gradle
- Android Studio will automatically sync Gradle
- Wait for dependencies to download
-
Build and Run
- Connect an Android device or start an emulator
- Click "Run" or press
Shift + F10
You can add this library to your Android project using JitPack.
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") }
}
}Add the dependency to your app/build.gradle.kts (or app/build.gradle):
dependencies {
implementation("com.github.Syedovaiss:NDJson-Parser:1.0.1")
}- Sync your Gradle files
- The library will be downloaded and added to your project
- Tap the "Select NDJSON File" button
- Choose an NDJSON file from your device
- The app will automatically parse the file
- Parsed JSON objects are displayed in beautiful cards
- Each card shows:
- Item number
- Number of fields
- Formatted JSON content
- 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
- Tap "JSON" to download as JSON array format
- Tap "CSV" to download as CSV format
- Files are saved to
Downloads/NDJsonParser/
{"name":"John Doe","age":30,"city":"New York"}
{"name":"Jane Smith","age":25,"city":"Los Angeles"}
{"name":"Bob Johnson","age":35,"city":"Chicago"}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
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m "Add some amazing feature" - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Kotlin coding conventions
- Use meaningful variable and function names
- Add comments for complex logic
- Write unit tests for new features
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2024 Syed Ovais Akhtar
Syed Ovais Akhtar
- GitHub: @syedovaiss
- LinkedIn: Syed Ovais Akhtar
- Medium: @syedovaiss
- Jetpack Compose for the modern UI framework
- Material Design 3 for the design system
- Kotlinx Serialization for JSON parsing
Made with β€οΈ using Kotlin and Jetpack Compose
β Star this repo if you find it helpful!