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

Support conversion from JSON to TOML? #117

Closed
ghost opened this issue Sep 30, 2021 · 1 comment
Closed

Support conversion from JSON to TOML? #117

ghost opened this issue Sep 30, 2021 · 1 comment
Assignees
Labels
feature New feature or enhancement request

Comments

@ghost
Copy link

ghost commented Sep 30, 2021

Is your feature request related to a problem? Please describe.
I could get the JSON string from TOML table by json_formatter, but how can I read it again from JSON file and parse to TOML table. Please help me if i did not notice that on the document, thanks.

Describe the solution you'd like
JSON string or file should be supported by parse function?

Additional context

@ghost ghost added the feature New feature or enhancement request label Sep 30, 2021
@ghost ghost assigned marzer Sep 30, 2021
@marzer
Copy link
Owner

marzer commented Sep 30, 2021

There's no built-in way to do this. The json_formatter exists for two reasons:

  1. Despite being an arguably poor config format, JSON makes for a pretty good over-the-wire/storage serialization format (and indeed is used very commonly for those purposes), so going from TOML to JSON is a reasonable use-case
  2. toml++ already has the TOML parser and data-types so implementing the json_formatter was super easy, barely an inconvenience

For me to go in the other direction (i.e. from JSON to TOML) I'd need to implement a complete JSON parser (plus all the weird offshoots and dialects), which isn't something I'm willing to maintain. Fortunately I don't need to, though; C++ is spoiled for choice when it comes to JSON libs:

If you need this functionality you could pair toml++ with your JSON lib of choice and implement it yourself relatively easily.

@marzer marzer closed this as completed Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement request
Projects
None yet
Development

No branches or pull requests

1 participant