码迷,mamicode.com
首页 > 其他好文 > 详细

jackson readTree

时间:2014-08-27 14:39:18      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:blog   java   io   ar   2014   div   log   on   new   

String jsonstr = "{\"msg\":{\"head\":{\"version\":\"1.0\",\"bizcode\":\"1006\",\"senddate\":\"20140827\",\"sendtime\":\"110325\",\"seqid\":\"1\"},\"body\":{\"datalist\":\"wahaha\",\"rstcode\":\"000000\",\"rstmsg\":\"成功\"}}}";
        ObjectMapper mapper = new ObjectMapper();  
        
        //允许出现特殊字符和转义符
        mapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true) ;
        JsonNode root = mapper.readTree(jsonstr); 
        
        JsonNode msg = root.path("msg");  
        JsonNode head = msg.path("head");  
        JsonNode body = msg.path("body");  
        
        String bizcode = head.path("bizcode").asText();  
        String datalist = body.path("datalist").asText();  
        
        System.err.println(bizcode);
        System.err.println(datalist);
        
        System.err.println(root.path("msg").path("body").path("datalist").asText());

  

jackson readTree

标签:blog   java   io   ar   2014   div   log   on   new   

原文地址:http://www.cnblogs.com/yangy608/p/3939315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!