duanmei1850 2015-03-10 11:25
浏览 25

PHP json双引号要求

PHP's JSON decode requires a JSON formatted with field names enclosed in double quotes like:

{"foo-bar": 12345, "myName": "Johnnie"}

But I have to parse some relatively complex JSON made by a Java application that is formatted with names without double quotes on field names like:

{foo-bar: 13456, myName: "Johnnie"}

...but more complex. Is there some easy way to fix this or am I screwed?

  • 写回答

1条回答 默认 最新

  • douzang7928 2015-03-10 11:34
    关注

    This requirement follows the JSON specification. If you look at the charts at http://json.org/ you will see that an object consists out of string:value pairs.

    JSON object description

    A string is defined to have quotes enclosing Unicode characters.

    JSON sring description

    The data you have is not valid JSON.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答