json 转换问题?
看透不说透
看透不说透 2017-03-28 09:16:07
0
2
1045

data:{"name":"xxx","age":23}

类似这样的字符串如何转成json

由于key不带双引号,不能直接转

但是如果给data加上双引号,如何split字符串?

用:分隔会造成{"name":"xxx","age":23}也被分隔。


看透不说透
看透不说透

reply all (2)
数据分析师

json conversion problem? - PHP Chinese website Q&A - json conversion problem? - PHP Chinese website Q&A

Take a look around and learn.

    迷茫
    var a = 'data:{"name":"xxx","age":123}'; //这步可以取到“{"name":"xxx","age":123}” var b = a.substring(a.indexOf("{"),a.lastIndexOf("}")+1); var c = $.parseJson(b);

    如果你必须要这个data在外包裹json数据的化,可以这样:

    var d = {}; d.data = c;
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!