Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

gson£¨JSON×Ö·û´®×ª»»³ÉÒ»¸öÏàµÈµÄJava¶ÔÏó£©

  Ä¿Ç°´ó¶àÊýʹÓÃgsonµÄ»¹ÒªÇóÔÚjavaÀàÖÐʹÓÃjava annotation£¬²»ÍêÈ«Ö§³ÖPOJO¡£
GsonÕâ¸öJavaÀà¿â¿ÉÒÔ°ÑJava¶ÔÏóת»»³ÉJSON£¬Ò²¿ÉÒÔ°ÑJSON×Ö·û´®×ª»»³ÉÒ»¸öÏàµÈµÄJava¶ÔÏó¡£GsonÖ§³ÖÈÎÒ⸴ÔÓJava¶ÔÏó°üÀ¨Ã»ÓÐÔ´´úÂëµÄ¶ÔÏó¡£
´úÂëÀý×Ó
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.json;
import com.google.gson.Gson;
/**
*
* @author ann
*/
public class JsonConverter {

public void toPerson(){
String json = "{'data1':100,'data2':'hello','id':1}";
Gson gson = new Gson();
Person p = gson.fromJson(json, Person.class);
System.out.println(" p :" +p.getId());
System.out.println("p:"+p.getName());


}
public void toJsonString(){
Person p = new Person();
p.setId(1);
Gson gson = new Gson();
String s = gson.toJson(p,Person.class);
System.out.println("s"+s);
}
public static void main(String[] args) {
JsonConverter convert = new JsonConverter();
convert.toPerson();
//convert.toJsonString();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.test.json;
/**
*
* @author ann
*/
public class Person {
private int id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}

}

ÏÂÔØhttp://code.google.com/p/google-gson/


Ïà¹ØÎĵµ£º

javaÄÚ´æ¹ÜÀí¼°ÄÚ´æй¶

    ±àÕß°´£ºJavaÄÚ´æй©ÊÇÿ¸öJava³ÌÐòÔ±¶¼»áÓöµ½µÄÎÊÌ⣬³ÌÐòÔÚ±¾µØÔËÐÐÒ»ÇÐÕý³££¬¿ÉÊDz¼Êðµ½Ô¶¶Ë¾Í»á³öÏÖÄÚ´æÎÞÏÞÖƵÄÔö³¤£¬×îºóϵͳ̱»¾£¬ÄÇôÈç
ºÎ×î¿ì×îºÃµÄ¼ì²â³ÌÐòµÄÎȶ¨ÐÔ£¬·Àֹϵͳ±ÀÅÌ£¬×÷ÕßÓÃ×ÔÒѵÄÇ×Éí¾­ÀúÓë¸÷λÍøÓÑ·ÖÏí½â¾öÕâЩÎÊÌâµÄ°ì·¨¡£
   
×÷ΪInternet×îÁ÷Ðеı ......

JavaÏ߳̽²½â

Ò» Ï̵߳Ļù±¾¸ÅÄî
Ïß³ÌÊÇÒ»¸ö³ÌÐòÄÚ²¿µÄ˳Ðò¿ØÖÆÁ÷.Ò»¸ö½ø³ÌÏ൱ÓÚÒ»¸öÈÎÎñ,Ò»¸öÏß³ÌÏ൱ÓÚÒ»¸öÈÎÎñÖеÄÒ»ÌõÖ´Ðз¾¶.
¶à½ø³Ì:ÔÚ²Ù×÷ϵͳÖÐÄÜͬʱÔËÐжà¸öÈÎÎñ(³ÌÐò)
¶àÏß³Ì:ÔÚͬһ¸öÓ¦ÓóÌÐòÖÐÓжà¸ö˳ÐòÁ÷ͬʱִÐÐ
JavaµÄÏß³ÌÊÇͨ¹ýjava.lang.ThreadÀàÀ´ÊµÏÖµÄ
JVMÆô¶¯Ê±»áÓÐÒ»¸öÓÉÖ÷·½·¨(public static void main( ......

Æô¶¯·ÇjavaÐéÄâ»ú·½Ê½ÏÂÔËÐÐmatlab

ÔÚ·ÇjavaÐéÄâ»úÏÂÔËÐÐmatlab¾Ý˵¿ÉÒÔÀ©´óÄÚ´æ,Æô¶¯·ÇjavaÐéÄâ»úÏÂÔËÐÐ matlabµÄ·½·¨ÓУº
Ò».
1¡¢ÓÒ½¨µãmatlab¿ì½Ý·½Ê½£¬Ñ¡ÊôÐÔ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ