Given an API that returns a jsonl, how can I manipulate the data that I obtain?
What if the API gives me data like this:
{"plate": "pizza", "quantity": 3}
{"plate": "pasta", "quantity": 2}
{"plate": "pizza", "quantity": 3}
{"plate": "pasta", "quantity": 2}
{"plate": "hotdog", "quantity": 7}
How can I do that maintaining the type .jsonl and not creating and array?
Thanks a lot for the help
According to jsonlines.org, each line in a jsonl file is a valid JSON value.
Thus, the approach would seem to be:
Something like this:
const lines = data.split(/\n/);
lines.forEach(line => {
const object = JSON.parse(line);
// Do something with object.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With