News for hackers. Stuff that matters.
Re:Ask HN: What are some tools / libraries you built yourself? by theFak on Sunday May 16, 2021 @12:41PM (#27174874)
How do you parse the text?
Re:Ask HN: What are some tools / libraries you built yourself? by noir_lord on Sunday May 16, 2021 @01:16PM (#27175215)
Really simply, I grab the json from the copy buffer, use `json_decode` then `var_export` and then use some horrible regex stuff to reformat that into a modern short array syntax.

So it looks like `json_to_array.sh --assign --clip` (if no clip just echoes the resulting PHP to stdout)

https://kopy.io/aLpar (its not good code, it's an itch scratcher) - only works on Linux (it's all I use but would be trivial to make it work on a Mac I think).

PHP makes a really good shell scripting language since it's a full blown language with a massive API and can 'talk' to the shell quite simply.