You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library should not have either of the methods: fromFile() nor fromStream(). Perhaps these could be kept around as a convenience, but a pure implementation should not have methods that deal with reading files or streams, because insodoing, the library only supports files and streams. If I wanted to use this library with a general purpose async framework like Amp or React, I can't, because it doesn't explicitly support them. A well designed implementation would not tie itself to particular data protocols, instead just accepting incomplete JSON fragments from a string buffer, like Duct.
The text was updated successfully, but these errors were encountered:
Luckily Json machine is not tied to any data protocol. Those methods are just convenient methods. If you look inside any of the from* methods, you'll see how it's done. Core implementation is based on an iterable which is internally consumed by foreach. You can pass it any iterable that produces chunks of json document. Example:
$jsonDocumentChunks = ['{', '"one": "two"', '}']; // or any iterable, be it array, Iterator or Generator$iterator = newJsonMachine($jsonDocumentChunks);
foreach ($iteratoras$item) {
// ...
}
@Bilge, if you want to contribute to README with an example of usage with Amp or React, feel free to do so. It will be appreciated.
This library should not have either of the methods:
fromFile()
norfromStream()
. Perhaps these could be kept around as a convenience, but a pure implementation should not have methods that deal with reading files or streams, because insodoing, the library only supports files and streams. If I wanted to use this library with a general purpose async framework like Amp or React, I can't, because it doesn't explicitly support them. A well designed implementation would not tie itself to particular data protocols, instead just accepting incomplete JSON fragments from a string buffer, like Duct.The text was updated successfully, but these errors were encountered: