Skip to content
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

I guess we're making a semi-blessed JS TOML parser for the website! #2

Closed
workingjubilee opened this issue Aug 29, 2019 · 5 comments
Closed

Comments

@workingjubilee
Copy link

workingjubilee commented Aug 29, 2019

Following up on this:

@workingjubilee Yes please! haha I hadn't figured out how to actually do that yet, but I found this site: https://toolkit.site/format.html so I knew it was possible.

@mojombo had a good point that some types aren't directly translatable, like native datetimes. What do we do in those cases? Maybe just output a string version of the datetime? Or replace the content with a comment (even though it isn't technically legal in JSON)? Likewise do you take a datetime string in JSON and try and covert it to native datetime for TOML?

Originally posted by @cannikin in #1 (comment)

We can do "lossy data, but structural match" or "lossy structure, but data match" translation across JSON : TOML, the data-lossless one involving type annotations embedded in the JSON structure. By default, we can favor the first, cleanest translation (where JSON and TOML are 1 to 1), but when the translation would involve loss of type data like that, we can display an error state or perhaps a "warning state" I guess and point the user to an option to enable alternative translations. After all, we already have to intelligently handle JSON literals ("Uh, Ma'am, this is a hash table").

I think recognizing JSON strings that are exact matches for the subsets of the RFC3339 format that TOML supports and casting them to TOML datetimes is a sane default, because it's lossless as a result, but not if they are off by even a single whitespace(!), and that a similar logic of Maximal Strictness would serve well on all type casts. No guessing and no magic, really, just return to user and comment on the results, maybe offer choices if we can. And I think that's going to be easiest.
Edited: I'm so sorry, I was mid-way through my coffee when I first posted this.

@pradyunsg
Copy link
Member

Or... We can drop that section. 🙃

I'm ambivalent to whatever we do here.

@cannikin
Copy link
Contributor

haha That's a possibility too. The reason I added it was when I start comping I wanted to include the TOML vs JSON vs YAML examples. I found a converter (first or second result in google for "toml converter") and I thought "the first result should be toml.io, not some random site". But that was probably my vanity speaking, not the pragmatic/lazy programmer speaking. ;)

@eksortso
Copy link

I wouldn't mind dropping that section. If we're pitching a human-readable, human-writable format (and we are), then letting people see what they can do, and letting it tumble around in their head for a bit, is what's important. The rest of the site can point them to the latest spec, solid implementations, and maybe live demos.

@workingjubilee
Copy link
Author

Aw, OK! It is definitely more of a nice-to-have.

Though, of nice-to-haves, maybe "an automatic TOML validator" would come first, which is really just folding instaparse.mojombo.com into toml.io.

@pradyunsg
Copy link
Member

Closing, since we've dropped that section. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants