Json与Object转换


Json与Object转换

依赖jar包:fastjson


            com.alibaba
            fastjson
            1.2.75

Object转Json

User user=new User();
String json=JSON.toJSONString(user);

Json转Object

String json="User{id=60223, name='neo', address='静安华山路250号'";
Hotel hotel = JSON.parseObject(json, Hotel.class);