5 ms·
I feel open parsing files is misguided. Downright wrong if it profilerates into scripts, because suddenly simple scripts can't work on JSON, because opening JSO
by lostmsu 7y ago
I feel open parsing files is misguided. Downright wrong if it profilerates into scripts, because suddenly simple scripts can't work on JSON, because opening JSON returns something different from a stream of lines.
- joshstrange 7y agoWell I imagine it respect the shebang at the top of the script so it will be run in the right shell where it doesn't parse or do any of this fancy stuff.
- dragonwriter 7y ago> I feel open parsing files is misguided. Downright wrong if it profilerates into scripts, because suddenly simple scripts can't work on JSON, because opening JSON returns something different from a stream of lines. Doesn't “open --raw” address that? https://book.nushell.sh/en/loading_data#opening-in-raw-mode https://book.nushell.sh/en/loading_data#opening-in-raw-mode Also, I suspect most simple scripts that want to work on JSON Will want to parse it, so the default makes them more easily able to work with it, not less.
- lostmsu 7y agoI am having a problem with --raw not being default. Defaults must be secure and stable.
- mkl 7y agoCan you explain why parsing JSON can't be secure or stable?
- lostmsu 7y agoThe problem is not with JSON parsing. It is with the fact, that people will use open without --raw to process, for example, Python files, because it is easy and works now. And some day later shell will learn to parse them into AST with open, and today's scripts will no longer work. Or worse start doing something very wrong.
- j88439h84 7y agoI agree. Mario provides read-text as well as read-json-array, read-json-dicts for each different type of file (json, csv, yaml, toml). https://github.com/python-mario/mario https://github.com/python-mario/mario
- felixfbecker 7y agoYeah, I prefer PowerShell's gc foo.json | cf-json Get-Content foo.json | ConvertFrom-Json I regularly use that to quickly visualize JSON data in tables