0

I have a really big JSON file, but actually, I need a few fields of the object. Can I parse only a small part of the given object in order to not spend a lot of time for this operation?

  • A JSON file is actually just a file containing text. Before you can use it as a JavaSript JSON object you will need to use JSON.parse(text) so the simple answer is no you can't. You could use streams and buffers to keep the memory usage down but you will still need to read the full text from the file before being able to parse it and use it as a JSON object in JavaSript. – Bojoer Dec 14 '20 at 10:47
  • @Bojoer You can use a *streaming JSON parser*, which allows you to work with parts of the file as they're being decoded, so you do *not* have to read the entire file *before* you can decode it. See the duplicate… – deceze Dec 14 '20 at 10:50

0 Answers0