当前位置:网站首页>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));
边栏推荐
- Multi mode concurrent implementation of tortoise and rabbit race in go language
- 剖析下零拷贝机制的实现原理,适用场景和代码实现
- mysql如何查询表的字符集编码
- Tencent cloud released orbit, an automated delivery and operation and maintenance product, to promote enterprise applications to be fully cloud native
- Sectigo ov pan domain name certificate is 1590 yuan a year easy to use
- mysql查询视图命令是哪个
- 腾讯云发布自动化交付和运维产品Orbit,推动企业应用全面云原生化
- mysql数据库扫盲,你真的知道什么是数据库嘛
- Li Kou today's question -535 Encryption and decryption of tinyurl
- R language uses GLM of mass package The Nb function establishes the negative binomial generalized linear model, and the summary function obtains the summary statistical information of the negative bin
猜你喜欢

0 basic self-study STM32 (wildfire) -- use register to light LED -- Explanation of GPIO function block diagram

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

DevCloud加持下的青软,让教育“智”上云端

mysql.sock的概念是什么

Redis principle - sorted set (Zset)

mysql数据库扫盲,你真的知道什么是数据库嘛

What are the usage scenarios for locks in MySQL

sequential detector

在线SQL转CSV工具

Opencv+YOLO-V3实现目标跟踪
随机推荐
0基础自学STM32(野火)——使用寄存器点亮LED——GPIO功能框图讲解
育润多维发力慈善领域,勇抗企业公益大旗
The R language inputs the distance matrix to the hclust function for hierarchical clustering analysis. The method parameter specifies the distance calculation method between two combined data points,
自学结构体(小甲鱼c语言)
关于Go中两个模块互相调用的场景解决方案
KUKA robot external axis configuration what you must know
R语言epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、aggregate.data.frame函数包含缺失值的情况下分组统计结果为NA
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将两个ggplot2可视化结果横向组合、接着再和第三个图像横向组合起来(三幅图各占比例为50%、25%、25%)
2022春夏系列 KOREANO ESSENTIAL重塑时装生命力
Kali installation tutorial 2020
Leetcode daily question - 535 Encryption and decryption of tinyurl
Interrupt怎么用
设置双击运行 jar 文件
SRM供应商协同管理系统功能介绍
Does MySQL support foreign keys
浏览器大尺寸截屏
High landing pressure of "authorization and consent"? Privacy computing provides a possible compliance "technical solution"
Scenario solution for two modules calling each other in go
R语言将距离矩阵输入给hclust函数进行层次聚类分析,method参数指定两个组合数据点间的距离计算方式、plot函数可视化层次聚类的树状图(dendrogram)
从居家办公中感悟适配器模式 | 社区征文