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);//取出值后再还原双引号
  • 相关阅读:
    数据结构八树和森林
    数据结构 七 二叉树的遍历
    python 的 encode 、decode、字节串、字符串
    TCP/IP
    pg 数据库操作
    nginx + lua 的 跳转命令
    lua string 下的函数
    lua 的匹配规则
    nginx的 ngx.var ngx.ctx ngx.req
    docker 网络模式 和 端口映射
  • 原文地址:https://www.cnblogs.com/blueskycc/p/5594483.html
Copyright © 2011-2022 走看看