I have my Android Java code that have to pass some array and some multidimensional array to the PHP Server. Unfortunately, I don't have the access to the PHP Server.
Here's the PHP Server API :
$result= array(
"username" => "admin",
"password" => "admin",
"hobbies" => array(
"1" => "science"
),
"skills" => array(
"1" => array(
"Boxing" => "Yes"
)
)
);
Here's my Android Java Code :
final String hobbies[] = {"science"};
final String skills[][] = {{"Boxing"},{"Yes"}};
@Override
protected Map<String, String> getParams() {
Map<String, String> jParams= new HashMap<String, String>();
JSONArray arrHobbies = new JSONArray();
JSONArray arrSkills = new JSONArray();
arrHobbies.put(hobbies[0]);
arrSkills.put(skills[0][0]);
jParams.put("username", "admin");
jParams.put("password", "admin");
jParams.put("hobbies",arrHobbies.toString();
jParams.put("skills",arrSkills.toString();
return jParams;
}};
Then, I use this code to see how the data've been sent.
Log.d("Response : ", jParams.toString());
It shows this on the Android Log :
{password=admin, username=admin, hobbies=["science"], skills=[["275]]}
UPDATE Here's the hash values when I debug the code:
0 = {java.util.HashMap$HashMapEntry@4884} "hobbies" -> "{"1":"1"}"
1 = {java.util.HashMap$HashMapEntry@4885} "password" -> "admin"
2 = {java.util.HashMap$HashMapEntry@4886} "username" -> "admin"
3 = {java.util.HashMap$HashMapEntry@4887} "skills" -> "{"1":{"Boxing":"Yes"}}"
I never succeed to communicate with the PHP Server API. Please help me where am I missing or wrong.
skills[][]is actually creating