當前位置:成語大全網 - 新華字典 - 請問如何將壹個屬性為java.sql.Date的Bean轉換成json字符串,然後再將json字符串轉換回Bean?請指教!!!

請問如何將壹個屬性為java.sql.Date的Bean轉換成json字符串,然後再將json字符串轉換回Bean?請指教!!!

妳需要使用第三方的lib文件:json-lib。

/usage.html

從Beans到JSON:

MyBean類{

私有字符串name = " json

private int pojoId = 1;

private char[]options = new char[]{ ' a ',' f ' };

private String func 1 = " function(I){ return this . options[I];}";

private JSON function func 2 = new JSON function(new String[]{ " I " }," return this . options[I];");

//getters & amp;安裝員

...

}

JSON object JSON object = JSON object . from object(new MyBean());

system . out . println(JSON object);

/*印花

{"name":"json "," pojoId":1," options":["a "," f"],

" func1 ":函數(I){ return this . options[I];},

" func2 ":函數(I){ return this . options[I];}}

*/

給妳:JSON對象JSON對象= JSON對象。來自對象(用戶);

從JSON到Beans:

String json = "{bool:true,integer:1,string:\ " JSON \ " } ";

JSON object JSON object = JSON object . from object(JSON);

BeanA bean =(BeanA)JSON object . tobe an(JSON object,BeanA . class);

給妳:

JSON object JSON object = JSON object . from object(JSON);

User bean =(User)JSON object . tobe an(JSON object,User . class);