如何把form表单里的数值改成json字符串

如何把form表单里的数值改成json字符串,第1张

若设定了dataType值json,那么返回数据格式必须为json格式正确的json数据格式如下,不能用单引号代替双引号正确:{"is_ok":true,"key":"value"}错误:{'is_ok':true,'key':'value'}php中可用json_encode()函数编码

var data=[ {'category': '01'},
{'category': '0101'},
{'category': '010101'},
{'category': '01010101'},
{'category': '01010102'},
{'category': '01010103'},
{'category': '010102'},
{'category': '0102'},
{'category': '010201'},
{'category': '010202'},
{'category': '02'},
{'category': '020101'},
{'category': '020102'} ];
var res=datafilter((o)=>ocategorylength==2)map((o)=>{
   osub=datafilter((o1)=>o1categorysubstr(0,2)==ocategory&&o1categorylength==4)map((o1)=>{
      o1sub=datafilter((o2)=>o2categorysubstr(0,4)==o1category&&o2categorylength==6)map((o2)=>{
         o2sub=datafilter((o3)=>o3categorysubstr(0,6)==o2category&&o3categorylength==8);
         return o2;
      });
      if(!o1sublength)o1sub=datafilter((o2)=>o2categorysubstr(0,4)==o1category&&o2categorylength==8);
      return o1;
   });
   if(!osublength)osub=datafilter((o1)=>o1categorysubstr(0,2)==ocategory&&o1categorylength==6);
   return o;
});
consolelog(res);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/10556728.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-09
下一篇2023-05-09

发表评论

登录后才能评论

评论列表(0条)

    保存