More thoughts on education

“I wish that our current educational approaches put much more emphasis on following one’s curiosity and asking ‘Why?’, rather than on memorization of facts and rote reproduction of processes. We can hardly blame students for not being curious when our educational system doesn’t generally reward that. So, sadly, it is surprising when a student asks ‘Why?'”

Steven Clarke

JSON Streaming Output

I recently put together a simple little bit of code to handle streaming large amounts of JSON formatted data to the browser.

In order for you to see any benefit from this, you will need to have the following scenario.

You have a response you’re sending back with some meta information about the response – maybe a response code, or error messages or a single record.

You also have a number of rows to send back as a member of the main JSON object.

These rows don’t all need to be the same object, but you can only have a single variable that you stream.

This allows you to fetch and send a single database row at a time instead of building up a huge response object in memory on the server.

It builds up a response that looks like this (the data in “rows” is streamed one line at a time):