Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7438557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:34:23+00:00 2026-05-29T10:34:23+00:00

Im writing a client/server app for android that sends a username and password to

  • 0

Im writing a client/server app for android that sends a username and password to the server and receives a status for that user account.

My php code is like this:

$return['login'] = 'success';   
echo json_encode($return);

and the text received by android is:

{"login":"success"}

but I still get an error when I try to decode the json string to read the parameters:

JSONArray jsonArray = new JSONArray(input);

exception:

02-10 11:54:37.743: WARN/System.err(332): 
    org.json.JSONException: 
         Value {"login":"success"} of type org.json.JSONObject 
         cannot be converted to JSONArray
02-10 11:54:37.779: WARN/System.err(332): 
    at org.json.JSON.typeMismatch(JSON.java:107)

So I guess Im missing something that php should send, but after reading on json.org I just can’t see what it is. I have tried adding brackets before and after, as well as wrapping it in another array like this:

$parameters['login'] = 'success';   
    $return['parameters'] = $parameters;
echo json_encode($return);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:34:24+00:00Added an answer on May 29, 2026 at 10:34 am

    You should be using JSONObject instead of JSONArray since you sending a key-value pair.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a client for a server that typically sends data as strings
I'm writing my first client/server android app, and need an advice regarding server architecture.
I am writing an Android app that talks to a Google App Engine server.
I'm writing an sample app to create a Server on Android and a client
I`m writing client-server app for windows using WinSock and I have class for server.
I'm writing a client-server app using BSD sockets. It needs to run in the
I am writing a client/server app in C++ and need to realize simple protocol
I'm writing a client-server app, in which the client has a determined memory address
I have a year's experience writing client code but none with server stuff. I
I am writing a client server iPhone app. The server is J2EE based. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.