当前位置:网站首页>Repair of JSON parsing errors in a collection
Repair of JSON parsing errors in a collection
2022-06-29 17:33:00 【It's a procedural ape with hair】
From two-stage acquisition JSON Format : more API Please click Register for interface test
One :
{“hwgOnlineId”:“554312”, “jiwuChatId”:“”, “phoneCategoryId”:“20006”, “cuxiaoSeq”:{voucherTitle:1,lhvoucherTitle:2,isXYuanNItemTitle:3,taogouyhTitle:4,giftTitle:5,limitGifts:6,ordersGifts:7,jrPromTitle:8,purchaseTitle:9,couponTitle:10,newcouponTitle:11,yfbTitle:12,rxfTitle:13,scodeTitle:14,pointTitle:15,freightfreeTitle:16,govTitle:17,jnbtTitle:18}, “blackCategoryCode”:“R9010501”}
Two :
{“pic”:“//imgservice.suning.cn/uimg1/b2c/image/rX4cM65dyr_4kndNFwLEgA.jpg_400w_400h_4e”,
“itemDomain”:“//”+document.location.hostname,
“resRoot”:“//script.suning.cn/project/pdsWeb”,
“shopCount”:1,
“sslStoreCode”:“”,
“addCartNumLimit”:“199”,
“favoriteStatusSwitch”:“1” == “1”,
“thirdEVoucherFlag”:“”,
“specialSSLFlag”:“”,
“sslLabelText” : “ Suning service ”}
Use it directly PHP Of json_decode Report errors
Solutions :
1、 Manual formatting , Will all "," Line break
2、 Delete the code line with content positioning error by half division method
3、 Filter the format after finding the problem line
4、 about json The format is mixed with javascript Code can also be used directly v8js Engine processing
Solution 1 ( Repair format ):
$str = file_get_contents(‘test.txt’);
KaTeX parse error: Undefined control sequence: \* at position 23: …reg_replace('@/\̲*̲[^/]+\*/@isU','…str);
s t r = s t r r e p l a c e ( ′ " + d o c u m e n t . l o c a t i o n . h o s t n a m e ′ , ′ " ′ , str = str_replace('"+document.location.hostname','"', str=strreplace(′"+document.location.hostname′,′"′,str);
s t r = s t r r e p l a c e ( ′ " 1 " = = " 1 " ′ , ′ t r u e ′ , str = str_replace('"1" == "1"','true', str=strreplace(′"1"=="1"′,′true′,str);
j s o n = j s o n d e c o d e ( json = json_decode( json=jsondecode(str);
if(!$json) j s o n = j s o n 2 a r r a y ( json = json2array( json=json2array(str);
var_dump(getJsJSON($json));
Solution 2 ( Use PHP-V8JS Expand ):
// With JavaScript Environmental execution JS
function getJsJSON($str){
$v8 = new V8Js();
KaTeX parse error: Expected '}', got 'EOF' at end of input: …}} a={ str}
return JSON.stringify(a);
}
b = getJsJSON()
";
try {
// Pass parameters to js
// $v8->str = $str;
// perform js
$code = v 8 − > e x e c u t e S t r i n g ( v8->executeString( v8−>executeString(func);
// Empty objects , Garbage collection .
unset($v8);
} catch (V8JsScriptException KaTeX parse error: Expected '}', got 'EOF' at end of input: … dump(e->getMessage());
dump( e − > g e t J s S o u r c e L i n e ( ) ) ; d u m p ( e->getJsSourceLine()); dump( e−>getJsSourceLine());dump(e->getJsTrace());
// dump(KaTeX parse error: Expected 'EOF', got '}' at position 11: e); }̲ if(code) c o d e = j s o n d e c o d e ( code=json_decode( code=jsondecode(code,true);
return $code;
}
j s = f i l e g e t c o n t e n t s ( ′ t e s t . t x t ′ ) ; v a r d u m p ( g e t J s J S O N ( js = file_get_contents('test.txt'); var_dump(getJsJSON( js=filegetcontents(′test.txt′);vardump(getJsJSON(js));
边栏推荐
- Bottom level internal skill cultivation
- NVIDIA安装最新显卡驱动
- What are the advantages of SaaS services
- LeetCode 每日一题——535. TinyURL 的加密与解密
- First batch! Tencent cloud's ability to pass the solution of the government affairs collaboration platform of the China Academy of ICT
- How to use interrupt
- Kali installation tutorial 2020
- R language ggplot2 visualization: use the patchwork package (directly use the plus sign +) to horizontally combine the two ggplot2 visualization results, and then horizontally combine them with the th
- R语言dplyr包filter函数通过组合逻辑(与逻辑)过滤dataframe数据中的数据、其中一个字段的内容等于指定向量中的其中一个,并且另外一个字段值大于某一阈值
- 反射
猜你喜欢

SpingMVC请求和响应

0基础自学STM32(野火)——寄存器点亮LED

What is the MySQL query view command

剑桥大学教授:经常吃早餐害处多,很危险 - 知乎

Online text digit recognition list summation tool

序列检测器
![[the sixth operation of modern signal processing]](/img/49/7844a00077e56fd4d73e3ba515f8a6.png)
[the sixth operation of modern signal processing]

迈动互联中标大家保险集团

人脸识别4-百度商用方案调研

Collaborative development of epidemic home outsourcing project 𞓜 community essay solicitation
随机推荐
mysql.sock的概念是什么
Custom handlerinterceptor interceptor for user authentication
线段树、树状数组模板(复制粘贴确实好用)
mysql在linux中2003错误如何解决
Epoll analysis
育润多维发力慈善领域,勇抗企业公益大旗
力扣今日题-535. TinyURL 的加密与解密
2022春夏系列 KOREANO ESSENTIAL重塑时装生命力
regular expression
基于STM32F103ZET6库函数独立看门狗(IWDG)实验
第42期:MySQL 是否有必要多列分区
Use SSH to pull codes
R language uses user-defined functions to write deep learning linear activation functions and visualize linear activation functions
R语言使用epiDisplay包的kap函数(kap.2.raters函数)计算Kappa统计量的值(总一致性、期望一致性)、对两个评分对象的结果进行一致性分析、评分的类别为多个类别
首批!腾讯云通过中国信通院政务协同平台解决方案能力评估
自动收售报机
2020版KALI安装教程
R language ggplot2 visualization: use the patchwork package (directly use the plus sign +) to horizontally combine the two ggplot2 visualization results, and then horizontally combine them with the th
迈动互联中标大家保险集团
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图