Replies: 2 comments
-
You could also use This is how I would see it:
Then use those results as such:
The obvious drawback is that performance wise, checking validity of up to 4 file formats could be too slow, but I didn't test that nice coverage btw |
Beta Was this translation helpful? Give feedback.
-
Thanks for your input. That does have drawbacks of potentially unmarshalling the entire document twice - once when finding the parser and again to do the lookup. With some re-working of the logic it's possible to only unmarshal the data once in which case this would be great. I'll leave this here for further ideas and input before I start working on it. |
Beta Was this translation helpful? Give feedback.
-
It would be nice if dasel could guess the data format when a parser is not defined.
Idea
Dasel will look at the given input and discover the data format (JSON for example).
This means the parser flag will no longer be required.
How can we actually detect the file type?
When reading from a file we can look at the extension... this is already done.
This idea is more around the parsing of some unknown string of characters that is piped into dasel.
<
it's XML.{
it's JSON.[
and ends with]
it's JSON.[
and doesn't end with]
it's TOML.Gotcha's
These are some pretty basic checks which could easily be caught out, but for general usage it may be good enough.
Does anyone have any ideas for this?
Beta Was this translation helpful? Give feedback.
All reactions