QByteArray parameters

97 views
Skip to first unread message

rica...@aevotech.com.br

unread,
Oct 27, 2014, 3:50:20 PM10/27/14
to qjsonrpc-d...@googlegroups.com
Hello,

What would be the best way to call a method with a QByteArray parameter? Currently I'm converting it to a QString with Base64 encoding, but it would be more efficient if the byte array could be serialized directly. Would I have to add support for it in QJsonValue?

Thanks,
Ricardo

Matt Broadstone

unread,
Oct 27, 2014, 3:56:51 PM10/27/14
to rica...@aevotech.com.br, qjsonrpc-d...@googlegroups.com
On Mon, Oct 27, 2014 at 3:50 PM, <rica...@aevotech.com.br> wrote:
Hello,

What would be the best way to call a method with a QByteArray parameter? Currently I'm converting it to a QString with Base64 encoding, but it would be more efficient if the byte array could be serialized directly. Would I have to add support for it in QJsonValue?


Hey!
This actually came up recently on the issues page. The problem is that JSON itself has no concept of byte arrays (even though javascript now does/or soon will). So there's not really a more efficient way to store it in the actual JSON messages sent over the wire. I could add convenience methods to automatically (de)serialize QByteArrays to/from base64, but it would also offer no performance enhancement. We could add support to the QJson classes to handle byte arrays, but then we wouldn't be compatible with outside systems (a large goal of this project). So, unless I'm completely missing something, I'm afraid there's not much we can do here.

Cheers,
Matt

 
Thanks,
Ricardo

--
You received this message because you are subscribed to the Google Groups "qjsonrpc-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qjsonrpc-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ricardo Costa

unread,
Oct 27, 2014, 4:53:43 PM10/27/14
to Matt Broadstone, qjsonrpc-d...@googlegroups.com
I see, there seems to be no universal solution. Some people suggested yEnc (http://en.wikipedia.org/wiki/YEnc) instead of base64, but that would require additional code while base64 is built into Qt.

Well, I'll keep the current solution for now. The convenience methods could be a nice addition though.

Thanks,
Ricardo
Reply all
Reply to author
Forward
0 new messages