Open adrianboston opened 8 years ago
No. Currently the concept of output stream is sequential. Tell()
does not affect the sequential property but seeking will make some streams difficult to write, or may not be possible at all.
Can you describe your usage scenario which requires seeking?
the usage is converting nice friendly json into a clunky unfriendly anti-json format. Is it necessary to use FileWriteStream or can one use the ostreamwrapper or a none FP stream yet still use the Outputstream found in jsonx. Thanks for the response.
You can use existing output streams, or you can implement your own output stream. For the latter case you only need to implement several functions in the concept. But if the JSON is not too large, StringBuffer should be suitable in most cases.
For conversion from JSON to other format, I think you actually only need to use Reader
(the SAX API) and create a handler to receive and process the events. You may refer to this example which converts JSON to JSONX.
jsonx is a good example. however, it seems to use a standard Reader and then use a Writer class with the handlers to receive and process events, aka bool String(). but.... perhaps im wrong there. ah. ok i see the !reader.Parse(is, writer) so i guess it is done on the Reader.
is there an api describing the "you only need to implement several functions in the concept"