I have to send the following data to a php web service using JSON
The format of data to be send is:
object1{key1:<>,key2:<>Array1({key1<>,key3<>array2 ( {key4:<>,array3({key5:<>}), {}, {},...) }}
My problem is: how can I send the array values to the web service?
manlio
19.1k14 gold badges83 silver badges138 bronze badges
asked Dec 21, 2011 at 8:29
1 Answer 1
iam able to add more elemnts to the array. check this
JSONArray datarr = new JSONArray();
JSONObject obj1;
JSONObject Array1 = new JSONObject();
try {
for(int i=0;i<4;i++){
obj1 = new JSONObject();
obj1.put("array1val", 5);
obj1.put("array2val", 2);
datarr.put(obj1);
}
Array1.put("Array1", datarr);
Log.v(null, Array1.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
the out put is
{
"Array1":
[
{
"array1val":5,"array2val":2
},
{
"array1val":5,"array2val":2
},
{
"array1val":5,"array2val":2
},
{
"array1val":5,"array2val":2
}
]
}
is this what your looking for?
duggu
38.5k12 gold badges120 silver badges114 bronze badges
-
yha did it. but problem is that i am able to send only one value ata time like: Array1[{"array1val":5,"arrayval2":2:}] in one time ths Array1[{"array1val":5,"arrayval2":2:},{"array1val":5,"arrayval2":2:}]Android_D– Android_D2011年12月21日 10:00:57 +00:00Commented Dec 21, 2011 at 10:00
default