PHP:类似 JSON 的数据格式,搜索解析器

发布于 2024-09-30 03:51:03 字数 334 浏览 0 评论 0原文

我想要一个类似 JSON 的数据格式,具有以下功能:

  • 支持数组(理想的情况是使用 [item; item; item] 作为表示法和 [key: value; key2: value2]),也
  • 支持嵌套字符串,非常适合以下内容: "foo",0x0a,"bar"
  • 十六进制数字,bin 数字,十进制数字

有谁知道这种数据格式的解析器用 PHP 写的?

JSON 太不灵活,因为键必须用引号引起来,并且关联数组的表示法与普通数组不同,并且缺少特殊字符的字符串连接。

I would like to have an JSON like data format with the following features:

  • support of arrays (ideal with [item; item; item] as notation and [key: value; key2: value2]), also nested
  • string support, ideal with the following: "foo",0x0a,"bar"
  • hex numbers, bin numbers, decimal numbers

Does anyone know a parser for such a data format written in PHP?

JSON is too inflexible, because keys must be in quotes and associative arrays have a different notation from normal ones and because of the missing string concatenation for special characters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Saygoodbye 2024-10-07 03:51:03

查看 YAML。它应该非常接近你想要的。它有列表和关联数组,了解多种数据类型。对十六进制数字的支持似乎取决于所使用的解析器。

它似乎不执行二进制数字,并且无法执行示例中概述的字符串连接,但是编写良好的解析器应该相对容易相应地扩展。此外,还提供了用户定义数据类型

这里是 PHP YAML 解析器的列表。

Take a look at YAML. It should come fairly close to what you want. It has lists and associative arrays, knows a number of data types. Support for hexadecimal numbers seems to depend on the parser used.

It doesn't seem to do binary numbers, and can't do string concatenation as outlined in your example, but a well-written parser should be relatively easy to extend accordingly. Also, there is a provision for user-defined data types.

Here is a list of PHP YAML parsers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文