tree_magic icon indicating copy to clipboard operation
tree_magic copied to clipboard

Detecting application/json

Open dbrgn opened this issue 8 years ago • 4 comments

Currently JSON files do not seem to be detected properly, but instead detected as application/json. Is this planned, or out of scope?

dbrgn avatar Apr 20 '17 08:04 dbrgn

I assume you're wanting it detected as text/json or the sort. It seems from reading around (see http://stackoverflow.com/q/477816) that application/json is the way to go for json filetypes. If you want to compare against something else, you should be able to use the match_* functions which should handle aliases like text/json or the like.

aahancoc avatar Apr 23 '17 02:04 aahancoc

Uh, sorry, yeah, I meant to write text/plain. And yes, application/json would be correct.

There are also others, e.g. YAML files are usually specified as text/yaml.

dbrgn avatar Apr 23 '17 10:04 dbrgn

Alright, got you. I just haven't gotten around to implementing that yet. Will soon, but I'm busy with schoolwork right now.

aahancoc avatar Apr 23 '17 14:04 aahancoc

There is also the problem that any valid json file is also a valid yaml and a valid toml file.

For many textual formats there is no good way to differentiate them except heuristics. (like any php .init is a differen but similar format as py .property files which can be equivalent to an toml file)

rustonaut avatar Oct 20 '17 15:10 rustonaut