Tuesday, January 8, 2013

Re: [android-developers] Re: Send multidimensional array via POST request?

In regards to George's reply.. that works.. but depending on the library you use (looking at you org.json.*) it could eat up a bit of memory... obviously something to avoid on phones/tablets if possible. Jackson has an additional library for support a JSONObject, but with the mapping features, you can stream parse into an object on the fly, using little memory, and/or spit out your object tree as a json string on the fly with little memory use as well.


On Tue, Jan 8, 2013 at 12:41 PM, Kevin Duffey <andjarnic@gmail.com> wrote:
JSON is the only way to go.. most compact, supports object trees easily, jackson is fast stream parser and can map to objects from json string and vice versa.. look it up, use it. You won't go back.


On Tue, Jan 8, 2013 at 11:56 AM, George Baker <spaceastronomer@gmail.com> wrote:
Sorry hit enter too quick. Example below. This creates a value of error containing two addtional name value pairs.

                       JSONObject msgJSON = new JSONObject();
msgJSON.put("error", new JSONObject());
msgJSON.getJSONObject("error").put("code", errorCode);
msgJSON.getJSONObject("error").put("message", msg);
                       String reponse = msgJSON.toString();



On Tuesday, January 8, 2013 2:54:00 PM UTC-5, George Baker wrote:
I would also recommend JSON.  As Nobu said it is compact and many server side programming languages have libraries readily available for it.  Otherwise as far as I know mimicking a  form post doesn't offer an input type that natively supports an embedded name value pair. 

Here's an example on how to write one

                      JSONObject msgJSON = new JSONObject();
msgJSON.put("error", new JSONObject());
msgJSON.getJSONObject("error").put("code", errorCode);
msgJSON.getJSONObject("error").put("message", new JSONObject());
msgJSON.getJSONObject("error").getJSONObject("message").put("lang","en-us");
msgJSON.getJSONObject("error").getJSONObject("message").put("value",errorMessage);
msgJSON.put("value",errorMessage);

On Saturday, January 5, 2013 12:03:01 PM UTC-5, Roman Bugaian wrote:
It's simly to send POST reaquest with Lists consisting of BasicNameValuePair, but how to send a pair, where a value is another list of pairs?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment