2015-05-26 16:42 GMT-03:00 Sven Van Caekenberghe <s...@stfx.eu>:
>> On 26 May 2015, at 19:24, Esteban A. Maringolo <emaring...@gmail.com> 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)

+1

> And maybe also
>
>  #readFromString: <string>

It could be implemented using #readFrom:

>  #readFromBytes: <bytearray>

This should also specify encoding, I think.


> For the writer, I am not so sure. Maybe
>  #nextPut: <object> toStream: <stream> (binary or character ReadStream as 
> appropriate)

> And maybe also
>  #toString: <object>

In this particular case it is all what I'd need, #fromString:/toString:

>  #toBytes: <object>

> Note that the reader and writer objects could be different.

This is also a requirement, particularly if you want to use NeoJSON/CSV

> But like I said, I am not so sure about the API. We could try to define a 
> Trait for this.

I think it's more an Interface/protocol (contract) rather than a trait.
But maybe because I don't know how a trait could be implemented to solve this.

Regards!

Esteban A. Maringolo

Reply via email to