This project is designed to handle large JSON data efficiently by streaming it in small chunks instead of loading the entire dataset into memory at once. This approach significantly improves page performance and optimization, especially when dealing with large datasets.
- Efficient JSON Streaming: Fetches large JSON data in chunks of 20KB per chunk.
- Dynamic URL Support: Allows fetching JSON from any valid URL.
- Search Functionality: Filters JSON data dynamically based on a search keyword.
- Memory Optimization: Prevents excessive memory consumption by streaming data instead of loading it all at once.
- React Frontend: Provides an interactive UI to load and search JSON data.
- Pagination Support: Users can load more data progressively using a "Show More" button.
- Node.js (Express.js)
- Axios StreamAxios Stream (for handling data streaming efficiently)
- JSONStream (for streaming JSON data)
- CORS (to handle cross-origin requests)
- React.js (with TypeScript)
- React JSON Viewer (
react-json-viewfor structured JSON display) - JSON Repair (
jsonrepairto fix broken JSON structures) - Axios Stream (for efficient data retrieval)
- The backend exposes an API endpoint:
GET /large-json-data?sourceUrl=<URL>. - The server fetches JSON data from the provided URL using Axios.
- The response is streamed using JSONStream, processing objects one by one.
- Data is chunked into 20KB-sized parts before being sent to the client.
- If a search keyword is provided, only matching objects are sent.
- Users input a JSON URL and click "Load JSON" to fetch data.
- Data is loaded incrementally in chunks to optimize performance.
- JSON data is displayed using
react-json-view, which formats it for better readability. jsonrepairis used to fix any malformed JSON before parsing and rendering.- Users can search for specific data by entering a keyword. If a search term is provided, the backend filters matching JSON objects and streams only the relevant data. The frontend processes and displays the search results dynamically.
- Additional data can be loaded using the "Show More" button, which progressively loads more chunks.
- Clone the repository.
- Install dependencies:
'npm install'
- Start the server:
'npm run dev'
The server will run at http://localhost:5001.
-
Navigate to the frontend directory.
-
Install dependencies:
'npm install'
-
Start the React app:
'npm start'
The frontend will run at
http://localhost:5173.
sourceUrl(required): The URL of the JSON data source.search(optional): A keyword to filter results.
GET /large-json-data?sourceUrl=
GET /large-json-data?sourceUrl=https://jsonplaceholder.typicode.com/photos
GET /large-json-data?sourceUrl=https%3A%2F%2Fjsonplaceholder.typicode.com%2Fphotos&search=d32776
This project is open-source and available under the MIT License.