Forums Register Login

passing response as json vs. string array

+Pie Number of slices to send: Send
Hello all.
I am working on a client server architecture application. for which I am using Restlets Clients Response and Http Connector For Remote procedure Call.
I want to pass two objects as response.
so I am creating json for both using Jakson object mapper.



now In order to pass it to the client I can
a)pass the above two json string as a string separated with a delimiter like'~'
b)pass a string array having two of these json strings.
c)create a json having two of these json strings its content //not able to implement.
d)send a restlet object

I really dont wana use a) there can be chances that my string contains the delimiter as the content value.
b)am facing a parsing error....
c)it is working fine for me... need to figure if there is any chance of data loss.
d)heavy response... want to avoid....and want to reduce no of client -server calls.

would like to know you comment on the above mentioned procedures for sending response.


Thanks for your time reading this post.
+Pie Number of slices to send: Send
I think the answer depends on the response content-type you want to have. If you are specifying application/json they you have to return a json string, so option c) is the correct choice. I am not sure what kind of data loss are you talking about in this case.
+Pie Number of slices to send: Send
Hello Nitesh,

So far option c i.e creating a JSON of a String arrays having JSON as content works for me. For 'data loss' i mean chance of my json breaking up due to the type of content. as there will be a lott of data being passed as json string.

Thanks
Trust God, but always tether your camel... to this tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3053 times.
Similar Threads
How to print java Map name/value pair through JSON object in JS
Reading a 'Collection' object from JSON
JSON, dynamically formatting, etc.
[jersey/jax-rs] json object value string has extra quotes, jsonp, service chaining‏
Javascript array to JSON object via jquery
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:28:34.