Using xstream with a custom non-xml text format

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using xstream with a custom non-xml text format

Carlos Ramos
Hello,

I'm looking for a java library that allows me to serialize/deserialize java beans to/from a custom text format that resembles json. I have been reading around the xstream site and the API looks incredibly nice and flexible. So I was wondering if  maybe I could write my own xstream driver for this custom format of mine and use xstream for my task.

So I have a few questions:

1- Does using xstream with a non-xml custom text based format makes sense, or is xstream xml centric and should probably not be used for this?.
2- If xstream is indeed an good choice for my task, has this been done before ?. Is there an example or documentation of using a custom format ?.
3- Does anyone knows of other libraries that could be used for this task ?

Thanks in advance for your time.

--
Carlos Ramos
Reply | Threaded
Open this post in threaded view
|

Re: Using xstream with a custom non-xml text format

Jörg Schaible-2
Hi Carlos,

Carlos Ramos wrote:

> Hello,
>
> I'm looking for a java library that allows me to serialize/deserialize
> java beans to/from a custom text format that resembles json. I have been
> reading around the xstream site and the API looks incredibly nice and
> flexible. So
> I was wondering if  maybe I could write my own xstream driver for this
> custom format of mine and use xstream for my task.
>
> So I have a few questions:
>
> 1- Does using xstream with a non-xml custom text based format makes sense,
> or is xstream xml centric and should probably not be used for this?.

XStream will also write/read JSON (with limits) and a custom "binary"
format:

http://xstream.codehaus.org/json-tutorial.html

> 2- If xstream is indeed an good choice for my task, has this been done
> before ?. Is there an example or documentation of using a custom format ?.

Basically you'll need a HerarchicalReader and HierarchicalWriter
implementation and a HierarchicalDriver that will create those two. Have a
look at the code of the BinaryStreamDriver and related files in the  
com.thoughtworks.xstream.io.binary package.

> 3- Does anyone knows of other libraries that could be used for this task ?
>
> Thanks in advance for your time.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using xstream with a custom non-xml text format

Carlos Ramos
Thanks for the reply Jörg, reading up the docs.

Cheers.


On Fri, Mar 22, 2013 at 10:51 AM, Jörg Schaible <[hidden email]> wrote:
Hi Carlos,

Carlos Ramos wrote:

> Hello,
>
> I'm looking for a java library that allows me to serialize/deserialize
> java beans to/from a custom text format that resembles json. I have been
> reading around the xstream site and the API looks incredibly nice and
> flexible. So
> I was wondering if  maybe I could write my own xstream driver for this
> custom format of mine and use xstream for my task.
>
> So I have a few questions:
>
> 1- Does using xstream with a non-xml custom text based format makes sense,
> or is xstream xml centric and should probably not be used for this?.

XStream will also write/read JSON (with limits) and a custom "binary"
format:

http://xstream.codehaus.org/json-tutorial.html

> 2- If xstream is indeed an good choice for my task, has this been done
> before ?. Is there an example or documentation of using a custom format ?.

Basically you'll need a HerarchicalReader and HierarchicalWriter
implementation and a HierarchicalDriver that will create those two. Have a
look at the code of the BinaryStreamDriver and related files in the
com.thoughtworks.xstream.io.binary package.

> 3- Does anyone knows of other libraries that could be used for this task ?
>
> Thanks in advance for your time.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Carlos Ramos