转载

Vardump 更新,支持打印各种 Java 数据结构,支持嵌套

1、更新支持同时 打印http请求的request的cookies,session,parameter。

//请求的url为http://localhost/?a=1&b=2&b=123
@RequestMapping("/index")
public String index(HttpServletRequest request) {
	Vardump.print(request);		
	return "index/index";
}

打印的效果如下

request(
    ParameterMap(
        {(string)"a" (length=1)=>
                String[](
                    [0]=>(string)"1" (length=1)
                )
        }
        {(string)"b" (length=1)=>
                String[](
                    [0]=>(string)"2" (length=1)
                    [1]=>(string)"123" (length=3)
                )
        }
    )
    cookies(
        (string)"{(string)"__guid"(length=6)=>(string)111872281.412025206174933600.1541334635043.79(length=45)}" (length=94)
        (string)"{(string)"JSESSIONID"(length=10)=>(string)EBD3C517709D3A58439311546492EEC9(length=32)}" (length=86)
        (string)"{(string)"monitor_count"(length=13)=>(string)63(length=2)}" (length=58)
    )
    session(
        {(string)"realName"(length=8)=>(string)"系统管理员" (length=5)}
        {(string)"img"(length=3)=>(int)0}
        {(string)"aname"(length=5)=>(string)"admin" (length=5)}
        {(string)"mobile"(length=6)=>(string)"13818135252" (length=11)}
        {(string)"dname"(length=5)=>(string)"行政部" (length=3)}
        {(string)"rid"(length=3)=>
                HashSet(
                    [0]=>(int)1
                )
        }
        {(string)"aid"(length=3)=>(int)23}
        {(string)"did"(length=3)=>(int)3}
        {(string)"email"(length=5)=>(string)"admin@lcfms.cn" (length=14)}
        {(string)"status"(length=6)=>(int)1}
    )
)

2、支持打印各种继承了Map与Collection接口的数据类型,比如Json

JSONObject object=JSONObject.fromObject("{/"employees/":[{/"firstName/":/"Bill/",/"lastName/":/"Gates/"},{/"firstName/":/"George/",/"lastName/":/"Bush/"},{/"firstName/":/"Thomas/",/"lastName/":/"Carter/"}]}");
Vardump.print(object);

打印结果如下

JSONObject(
    {(string)"employees" (length=9)=>
                JSONArray(
                    [0]=>
                        JSONObject(
                            {(string)"firstName" (length=9)=>(string)"Bill" (length=4)}
                            {(string)"lastName" (length=8)=>(string)"Gates" (length=5)}
                        )
                    [1]=>
                        JSONObject(
                            {(string)"firstName" (length=9)=>(string)"George" (length=6)}
                            {(string)"lastName" (length=8)=>(string)"Bush" (length=4)}
                        )
                    [2]=>
                        JSONObject(
                            {(string)"firstName" (length=9)=>(string)"Thomas" (length=6)}
                            {(string)"lastName" (length=8)=>(string)"Carter" (length=6)}
                        )
                )
    }
)

3、处理打印null报错的异常。

4、更新使用文档

原文  https://www.oschina.net/news/102025/vardump-20181122-released
正文到此结束
Loading...