Skip to main content

Which data format for end-to-end application

7 replies [Last post]
azpublic
Offline
Joined: 2007-09-10
Points: 0

Hi,

i'm coding a J2ME and J2EE application end-to end and I was wondering what the pros out there would reccomend as a data format to communicate between the j2me client and the j2ee server.

I thought about webservices but maybe it is a little overkill and not all devices support webservices...
I also thought about custom XML with a litle xml parser in the j2ME client...?

I want to reduce bandwidth consumption at the maximum as the j2me app will be intensively querying the server but I also want the format used to be simple and that's why I thought of XML.

What do you guys usually use ? What is the actual reccomendation ?

Thanks

Message was edited by: azpublic

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
azpublic
Offline
Joined: 2007-09-10
Points: 0

Thank you all for your replies and support.

I'm now hesitating between the pros and cons of JSON vs RMI.
I am going to be sending a lot of images (PNG) to the midlet so the lightest the interchange format, the best.

From what I understand (correct me if I'm wrong):

Using JSON will ensure more portability as the output could be used on other non JAVA based clients as well. BUT it will be heavier in terms of data transfer.

Using RMI and sending serialized objects directly will be lighter in tems of bandwidth but less portable as the client will inevitably need to be a JAVA client.

I guess I will go for RMI for now and eventually adapt my server code to provide JSON or XML format when needed.

Let me know what you think.

C. Enrique Ortiz

I spent sometime looking into this, into JSON, as I haven't used before
for data exchange. I'll say that I actually like JSON due to its
simplicity, and its structure, that is based on name/value pairs.

There is a good comparisson of JSON vs. XML here:
http://www.json.org/xml.html

And a JSON parser source code in Java at:
http://www.json.org/java/

That said, JSON doesn't seem to support a clear or a good way to
represent binary data, such as the images that you want to transport.

ceo

meinterest@mobileandembedded.org wrote:
> Thank you all for your replies and support.
>
> I'm now hesitating between the pros and cons of JSON vs RMI.
> I am going to be sending a lot of images (PNG) to the midlet so the lightest the interchange format, the best.
>
> >From what I understand (correct me if I'm wrong):
>
> Using JSON will ensure more portability as the output could be used on other non JAVA based clients as well. BUT it will be heavier in terms of data transfer.
>
> Using RMI and sending serialized objects directly will be lighter in tems of bandwidth but less portable as the client will inevitably need to be a JAVA client.
>
> I guess I will go for RMI for now and eventually adapt my server code to provide JSON or XML format when needed.
>
> Let me know what you think.
> [Message sent by forum member 'azpublic' (azpublic)]
>
> http://forums.java.net/jive/thread.jspa?messageID=237683
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>
>
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Roger Riggs

Hi,

I think I would lean towards JSON, it is easy to produce and consume
and is flexible and extensive in almost any platform.

But for binary data like images, I would suggest just putting the URL of
the image into the JSON structure.
That will allow a separate mechanism for retrieval that can more easily
support caching and asynchronous retrieval and local storage.

$0.02, Roger

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

C. Enrique Ortiz

Smart, Roger!

ceo

Roger Riggs wrote:
> Hi,
>
> I think I would lean towards JSON, it is easy to produce and consume
> and is flexible and extensive in almost any platform.
>
> But for binary data like images, I would suggest just putting the URL of
> the image into the JSON structure.
> That will allow a separate mechanism for retrieval that can more easily
> support caching and asynchronous retrieval and local storage.
>
> $0.02, Roger
>
> ===========================================================================
>
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

sfitzjava
Offline
Joined: 2003-06-15
Points: 0

There is a small XML parser called NanoXML which is very lightweight, but in the end you are still taking java to XML and back.

Another option if you want really small and can live with a few limitations, look at MDO.dev.java.net, that is project I have built to transport DataObjects from a JavaEE server to ME devices, and used to save the records in the RMS as well. It's a simple object data serialization that is a bit more work but more resilient to the serialization version issue/bug.

Json is nice but still uses a lot of bandwidth, not to mention the size of the extra libraries to parse it.

-Shawn

terrencebarr
Offline
Joined: 2004-03-04
Points: 0

Bruno, thanks for answering this one. Yep, I would suggest JSON as well and our open source JSON/XML parser.

Hope that works for you.

-- Terrence

brunogh
Offline
Joined: 2006-04-23
Points: 0

Hi,

maybe take a look in JSON:
http://json.org/

There is a ME parser in that page, but it is also hosted in Mobile Ajax (https://meapplicationdevelopers.dev.java.net/mobileajax.html).

Thanks,
Bruno