This week's book giveaway is in the Spring forum. We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line! See this thread for details.
I nead to send the JSON object fro the client. I have made a JSON object containing the data that needs to be sent. My client is a android phone and needs to write data to a Web Service (already implemented and working) over a Request object and then read the response. How do you send a JSON object over a request.
Some sample code will be good, as i am new to JSON.
I nead to send the login information in the format :{"Email":"abc@xyz.co","Password":"123456"} and then read the user login information back via JSON. Really stuck on this. This is what i am trying. This code is from my android client.
The server reads the data from a variable called jsonRequest. That's why the line tagged with 1 will sets the header variable and its value. responseStr in the last line should hold the value of the user information from the server in the form of a JSON object. I can parse the object but its not working. Where am i going wrong. Really stuck in this, so any help would be appreciated.
What does "it's not working" mean? Is the HTTP request being sent as you want it to be sent? Is the server receiving all data correctly? If so, does it return all data as it should? And finally, what is the response received on the device?
Also, if you want to send a POST, why are you using HttpGet?
(As an aside, and as I told you before in the other thread where you asked about this, there's nothing at all Android-specific about this.)
Request:{"Email":"abc@xyz.com","Password":"123456"}
The above structure is sent to Server in a variable named “json”
If the request is successful a JSON Object is returned with the user details. If i provide the actual url for the web service could you try and send a request and see what you recieve at your end.
I posted this address in firefox and it printed {"error","-1"}. that was expected. So the web server is working fine. So whats then wrong with this code
All really that i have to do is send a variable called json with the jason object in it. I think things should be much clearer .