Search code examples
c#linq-to-json

Need to run LINQ queries on several hundred JSON files in child folders


Using c#:

I have a few hundreds of JSON files in nested folders in file system. I need to run LINQ queries within the data in files and find the JSON files that their JSON data matches certain crieria.

I can simly serialize all the JSON files in a List, then run my LINQ query on the array. However the approach takes lots of memory since I am reading all data from disk.

Is there any way to run my LINQ query on JSON files in file system without loading all of them in memory?


Solution

  • You should be able to stream the data as described in the following posts or something similar. This should help with the memory issues. How to parse huge JSON file as stream in Json.NET?, Parsing large json file in .NET