User User =NewUser (); User.setphone ("11111111"); User.setnmae ("Zhang San"); User.setphone ("TWTWTWTWTWTWTWTWTWTWTWTWTWTWTWTWTW"); List<User> users =NewArraylist<>(); Users.add (user); Users.add (user); Users.add (user); User=NewUser ("Ggggggggg", "3333333333", "0000000"); Users.add (user);//Property FilterPropertyFilter PF =NewPropertyFilter () {@Override Public Booleanapply (object o, String S, Object O1) {if("Name". Equals (s)) { return false; } return true; } };//FilterString jsonlist =json.tojsonstring (users, pf);/*---------------------------Fastjson---------------------------*/ //Fastjson, object converted to JSONString JSON =json.tojsonstring (user);//convert strings to ObjectsUser U = json.parseobject (JSON, user.class);//Collection Conversionslist<user> US = Json.parsearray (JSON, User.class); /*---------------------------Gson---------------------------*///Object Goto JSONGson Gson =NewGson (); JSON=Gson.tojson (user);//JSON goto ObjectU = Gson.fromjson (JSON, User.class);//Collection ConversionsList<user> UGS =gson.fromjson (JSON,NewTypetoken<list<user>>() {}.gettype ());//List Object CollectionGson gsonlist =NewGson (); JSON= Gson.tojson (users);
Android JSON parsing the use of Fastjson and Gson