-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I add TOML support? #40
Comments
TOML is definitely on the todo list. I looked into it a while back, and found one existing PHP library that is... rather dated but probably still works? https://github.com/leonelquinteros/php-toml (If you know a better one, I'm all ears.) For the most part, TOML should be reasonably straightforward; its Formatter would probably look an awful lot like the YAML formatter. The catch is that TOML has variable depth structure; its section headers can be either section headers or inline, at any level. That's no issue on deserializing, but when serializing, how do you know what level it should switch from headers to inline key names? I haven't figured out the answer to that yet, as I don't know what's conventional in the TOML-using community. (That said, I've not spent much time trying to answer it. It may be that just defaulting to "2 levels in header, rest inline" or something would cover the 95% use case, with a constructor override on the formatter like YAML does. If that is the case, I think that's a reasonable solution.) |
I haven't tested These 2 exist as well but same issue, only compliant with v0.4.0: So a good first step might be to either upgrade those to 1.0.0, write a new library (probably out of scope), or just say "only 0.4.0 is currently supported". I looked around at some popular Rust crates I just threw a bunch of examples into this:
I looked at these files: It could be different in other ecosystems but to my knowledge Rust is the most popular user of TOML. |
Hm. Yeah, I'm not finding any TOML 1.0-compatible libraries for PHP so far. I'm not sure adding 0.4 support to Serde directly is wise, given how out of date it is. Building a new TOML library would definitely be out of scope; that should be its own library that Serde (and others) can leverage. Or upgrading one of the existing libraries, which is then a matter for those libraries. A Serde-TOML 0.4 bridge should be feasible, but I'd rather not include that directly. Adding additional formatters is trivial, though, so easily done outside of Serde itself. I'll leave this ticket open for now, but I consider it on ice until there's a TOML 1.0 library we can leverage. At that point, I'm full on board with adding it. |
This may have resolved itself: https://github.com/vanodevium/toml |
Now available in Serde 1.3. |
Just watched your talk, love it! I work with PHP and Rust professionally so I'd love to convince my team to use this. I would like to add TOML support if you are open to it.
The text was updated successfully, but these errors were encountered: