当前位置:网站首页>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));
边栏推荐
- 0基础自学STM32(野火)——寄存器点亮LED
- Sectigo ov pan domain name certificate is 1590 yuan a year easy to use
- 卷妹带你学jdbc—2天冲刺Day1
- High landing pressure of "authorization and consent"? Privacy computing provides a possible compliance "technical solution"
- R语言使用MASS包的glm.nb函数建立负二项广义线性模型(negative binomial)、summary函数获取负二项广义线性模型模型汇总统计信息
- 一次采集JSON解析错误的修复
- 自学结构体(小甲鱼c语言)
- About Kali using xshell connection
- sequential detector
- C language practice ---- pointer string and linked list
猜你喜欢
随机推荐
linux中mysql 1045错误如何解决
About harbor private warehouse forgetting the login password
0 basic self-study STM32 (wildfire) - register lit LED
0基础自学STM32(野火)——寄存器点亮LED
基于STM32F103ZET6库函数定时器中断实验
Can MySQL views create indexes
力扣每日一题 06.29 两数相加
What are the advantages of SaaS services
MySQL触发器如何创建与删除
KUKA机器人外部轴配置你一定要知道的那些知识
Collaborative development of epidemic home outsourcing project 𞓜 community essay solicitation
R语言使用自定义函数编写深度学习Leaky ReLU激活函数、并可视化Leaky ReLU激活函数
How MySQL queries character set codes of tables
Online text digit recognition list summation tool
PCB板框的绘制——AD19
Bottom level internal skill cultivation
跨境独立站语言unicode转希伯来语
卷妹带你学jdbc—2天冲刺Day1
The R language uses the KAP function (kap.2.raters function) of epidisplay package to calculate the value of kappa statistics (total consistency, expected consistency), analyze the consistency of the
SRM系统可以为企业带来什么价值?








