> On 26 May 2015, at 21:54, Norbert Hartl <[email protected]> wrote: > >> >> Am 26.05.2015 um 21:42 schrieb Sven Van Caekenberghe <[email protected]>: >> >> >>> On 26 May 2015, at 19:24, Esteban A. Maringolo <[email protected]> wrote: >>> >>> It could be dead simple as specifying the class if the different JSON >>> libraries shared a common to/from API selectors, but they don't. >> >> Yes, it would be very good if there was such a thing as a common API for any >> reader/writer of any format (JSON, CSV, XML, STON, FUEL, ...). >> >> For a reader that is pretty easy, I think. Any reader object should >> understand >> >> #readFrom: <stream> (binary or character ReadStream as appropriate) >> >> And maybe also >> >> #readFromString: <string> >> #readFromBytes: <bytearray> >> >> For the writer, I am not so sure. Maybe >> >> #nextPut: <object> toStream: <stream> (binary or character ReadStream as >> appropriate) >> >> And maybe also >> >> #toString: <object> >> #toBytes: <object> >> >> Note that the reader and writer objects could be different. >> >> But like I said, I am not so sure about the API. We could try to define a >> Trait for this. >> > I'd like to have #readFrom:as: . Some of the mappers instantiate common > classes that should be overwritable. Of course this does not apply for e.g. > fuel. > > Norbert
Hmm, that would become quickly much more complex than I intended it to be. More complex configuration should be done up front when you configure the reader or writer object, I think. The idea is to find a usage common API.
