string和json转换的简单应用

 

 

import com.alibaba.fastjson.JSON;

        String strjson = request.getParameter("param");

        //url-json的转码解码
        String urlJson = URLEncoder.encode(strjson, "UTF-8"); 
        String strJson = URLDecoder.decode(urlJson, "UTF-8");

        //fastjson的转码解码
        Map<String, Object> paramlist = (Map<String, Object>) JSON.parse(strjson);
        String jsonStr = JSON.toJSONString(paramlist);
        
        //string和数组的转换,用,分割
        String ipArray [] = {"192.168.1.16","192.168.1.17","192.168.1.18"} ;
        String str = StringUtils.join(ipArray, ",");
        String [] strArr= str.split(",");

 

 

over

 

posted on 2016-09-20 16:00  光标  阅读(891)  评论(0编辑  收藏  举报

导航