Read about how to send data to server in android using json, The latest news, videos, and discussion topics about how to send data to server in android using json from alibabacloud.com
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
I can resolve JSON data in two formats; One is normal, and the other is in the form of an array; Common form:The JSON data format returned by the server is as follows: { "
The examples in this article describe how Android programmatically parses JSON-formatted data. Share to everyone for your reference, specific as follows:
Package Com.practice.json;
Import Org.json.JSONArray;
Import org.json.JSONException;
Import Org.json.JSONObject;
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.util.Log; public class
The second method of data interaction between the Android client and the server is android server.
There are many examples on the Internet to demonstrate how the Android client interacts with the
HTML code:
Background code (ajax_do.aspx.cs ):
String callback = request. querystring ["Callback"];
Response. Write (callback + "({MSG: 'error action! '})");
Jsonp principle:
Register a callback on the client, and then pass the callback name to the server.
In this case, the server is converted into JSON data.
Th
Ordinary form of:The JSON data returned by the server side is formatted as follows:
The code is as follows
Copy Code
{"Userbean": {"Uid": "100196", "ShowName": "U75afu72c2u7684u7334u5b50", "Avtar": null, "state": 1}}
The analysis code is as follows:
The code is as follows
Copy Code
TODO State Pro
Use of the jQuery form plugin -- Process JSON, XML, HTML data returned by the server, and jqueryjson
Code details:
Create a json. jsp file:
Create an xml. jsp file:
Create an html. jsp file:
I. project background there is a very wide application in Android development: the Android project obtains the resources of another web project or the data returned. This document obtains the JSON data returned by the web project. Androi
The example in this article describes how Android realizes reading and writing JSON data. Share to everyone for your reference. Specifically as follows:
1. Parse JSON:
Package De.vogella.android.twitter.json;
Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStream;
Import Java.io.Inp
Test results for recent projects, Android cannot proactively invoke
Webview.loadurl ("javascript: +callbackfunction+" (' +data+ ")"); This way the jsonobject type of data to JS, because JS over there is a string object.
At the same time, JS active call Android Object way, Android
Nonsense not much said, directly to everyone to paste code, the specific code as follows:
New json.jsp File:
New xml.jsp File:
Create a new html.jsp file:
The above is a small set up for you to share the jquery form plug-ins using the processing server returns JSON, xml,html data, hope to be helpful.
Android data loading and Json parsing-Original Version
1. Create an object class for data download
class MyData { String imagepath; String title; String desc; public MyData(String imagepath, String title, String desc) { super(); this.imagepath = imagepath;
In android, sometimes we don't need to use the local SQLite database to provide data. More often, we need to get data from the network. How can Android get data from the server? There are many types.
I. Methods for obtaining
Explain how the Java server provides the interface to the mobile terminal, in what data format to provide, the mobile side is how to request the server, receive and parse the return data.Service side: Or in the original S2SH framework of the project (build ssh detailed steps and related instructions), to join the servlet to provide interface to the terminal thing
When you use the HttpPost method to submit JSON data to the server in your project, the JSON data received on the server is garbled, looking for a number of methods, and finally one solves my problem, part of my code is as follows
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.