this post was submitted on 04 Jul 2024
24 points (92.9% liked)

Programming

17416 readers
44 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 6 points 4 months ago (1 children)

Yesterday, when I had a file with a list of JSON objects, and I wanted to move the date field at the end to the beginning, so I used regex find and replace to move it. Something like \{(.*?), ("date": ".*?") in Search, and then {$2, $1 in replace (or something close to it).

Yes, I refactor code and data using regex. I can't be arsed to learn AWK (even though I should).

[–] [email protected] 3 points 4 months ago (1 children)

AWK doesn't work with json IIRC. You have to use jq to deal with json.

[–] [email protected] 1 points 4 months ago

While yes, the way I had it structured looked like a CSV if you squinted a little, I do fully agree AWK can't be used for just any old JSON.

jq is dope, but that language still feels pretty confusing IMO.