For a rest API, I need to serialize big and deeply nested json objects;
Is there a way to echo the json while it is generated?
If I echo json_encode($var)
, it will generate the whole json and then spit it out: it costs memory, and I have to wait for the whole generation to be complete, before I start to see some response in my browser.
Is there any way to force json_decode to have this kind of behaviour?
Or are there libraries that can do this kind of stuff?