Reputation: 23
I'm working on a React Native project and need to process a .jsonl
(NDJSON) file that is stored locally within my project directory. I've been facing issues trying to read and parse this file using various methods and libraries. Here's what I have attempted so far:
import ndjsonStream from 'can-ndjson-stream';
const d = ndjsonStream('../d.jsonl');
However, this approach isn't working as expected. It doesn't seem to correctly handle the local file path or stream the NDJSON data.
import d from '../d.jsonl';
This method is not supported for NDJSON files, and it throws an error.
fetch
:const response = await fetch(filePath);
When I try to fetch the file using this method, I encounter a network error, likely because the file is stored locally and not on a remote server.
Are there any recommended methods or libraries specifically for handling NDJSON (JSON Lines) files in React Native?
How can I properly read and parse a local NDJSON file in a React Native environment?
Upvotes: 1
Views: 113