POST
it's a simple solution for transmission data to server, and server can capture the value by pair-element(like php, $_POST['company'])
- Example from J2ME
try {
HttpConnection c = (HttpConnection)Connector.open(URL);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty( "Content-Type" , "application/x-www-form-urlencoded" );
String msg = "uuid=444566&imei=9ddd999&jblend_license=2223" ;
byte [] data = msg.getBytes();
for ( int x= 0 ;x<data.length;x++)
System.out.print(data[x]+ "," );
c.setRequestProperty( "Content-length" , "" +msg.getBytes().length);
OutputStream os = c.openOutputStream();
os.write(data);
os.flush();
int rc = c.getResponseCode();
System.out.println( "" +rc);
} catch (IOException e) {
System.out.println( "IOException:" +e.getMessage());
}
|
XML design for describing data.
it's Rich Documents : easy to describe the complex structure
it's Metadata
it's Configuration Files : using to set software parameter
- Example
<?xml version= "1.0" ?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
|
- who use XML
ANT, Android's layout ... etc
it's a light-weight language for exchange data. the JavaScript can easy read it by eval(). but it's not only for JavaScript
{ "2" : { "nick_name" : "kan" , "full_name" : "Kan Kan" }, "4" : { "nick_name" : "mitsuhiko" , ...}, ...}
|
- who use JSON
plurk, facebook, twitter
- Example
Name: Gary
Profile:
Birth: 1975 - 04 - 43
Addr:
- City: Taipei
Road: Chung-Shoang
Number: 20
Flood: 3
- City: TaoYuan
Road: LongChung
Number: 10
Flood: 2
Blood Type: A
Score: 0.98
|
- Who use YAML
Google app engine(configure file)
Server -> Client : JSON or XML
Client -> Server : POST
For example, the PLURK API for search function:
- Returns the latest 20 plurks on a search term.
- Required parameters:
- api_key: Your Plurk API key.
- query: The query after Plurks.
- Optional parameters:
- offset: A plurk_id of the oldest Plurk in the last search result.
- Successful return:
A JSON list of plurks that the user have permissions to see:
[{ "id" : 3 , "content" : "Test" , "qualifier_translated" : "says" , "qualifier" : "says" , ...}, ...]
|
table. the result of comparing each format
|
POST
|
XML
|
JSON
|
YAML
|
readability
|
low
|
high
|
median
|
high
|
performance
|
high
|
low
|
median
|
median-high
|
security
|
low
|
high
|
median
|
median
|
security : parser for checking well-form
the purpose of stage activation get report on server(grails)
it's not complication structure(tree or nest)
it's not need to high readability
it's not need to easy to integrate each platform(like different web-platform, mobile...)
it's only good at security