zoukankan      html  css  js  c++  java
  • php接收到的json格式不标准,某个字段中的文本包含双引号的处理

    $str = '[{"Count":"1789"},{"裁判要旨段原文":"本瑶","案件类型":"3","裁判日期":"2013-04-02","案件名称":"王新华与杭州市"规划局"一审行政判决书","文书ID":"a1b0b3ef-cd55-4bd2-a892-b86564cd3091","审判程序":"一审","案号":"(2013)杭拱行初字第5号","法院名称":"杭州市拱墅区人民法院"}]';

    $str = '[{"Count":"1789"},{"裁判要旨段原文":"本瑶","案件类型":"3","裁判日期":"2013-04-02","案件名称":"王新华与杭州市"规划局"一审行政判决书","文书ID":"a1b0b3ef-cd55-4bd2-a892-b86564cd3091","审判程序":"一审","案号":"(2013)杭拱行初字第5号","法院名称":"杭州市拱墅区人民法院"}]';
    
            $str = str_replace('{"','@@@',$str);
            $str = str_replace('":"','###',$str);
            $str = str_replace('"}','!!!',$str);
            $str = str_replace('","','%%%',$str);
    
            $str = str_replace('"','&&&',$str);
    
            $str = str_replace('@@@','{"',$str);
            $str = str_replace('###','":"',$str);
            $str = str_replace('!!!','"}',$str);
            $str = str_replace('%%%','","',$str);
    
        
            $arr = json_decode($str,true);
        
            $a = str_replace('&&&','"',$a);//取出值后再还原双引号
  • 相关阅读:
    Jenkins安装
    Python操作yaml文件
    class 中构造函数与析构函数
    python发送邮件(yagmail模块)
    filter、map函数的区别
    python redis操作
    多个 python的pip版本选择
    python Excel操作
    python MD5操作
    缓存淘汰算法之LRU实现
  • 原文地址:https://www.cnblogs.com/blueskycc/p/5594483.html
Copyright © 2011-2022 走看看