I'm trying to write a JSON web sources script but I'm having an issue being able to output the current line/value as-is without any whitespace trimming happening.
A random example of a MusicBrainz release in JSON: https://musicbrainz.org/ws/2/release/b1ba816e-2da4-4bf6-9c2b-4a743cb19b65?fmt=json&inc=artists
The part giving me trouble is the
artist-credit array, specifically
artist-credit.0.joinphrase. Its value is
" & ": an ampersand with a leading and trailing space.
If I use
SayRest it'll trim both the leading and trailing whitespace, resulting in
If I use
SayRegexp ".*", I'll get
Artist1& Artist2, only trimming the leading whitespace.
How can I Say the value without any trimming happening? I.e. I want the result:
Artist1 & Artist2.
My current approach is to try and at least get the formatting somewhat correct using:
json_foreach "artist-credit" ifnot "0" json_select "joinphrase" ifnot "" unspace if "," sayregexp ".*" else say " " sayregexp ".*" endif endif endif json_foreach_end
But due to how releases are credited, this is bound to mess up on some attempts at tagging. Ideally, I wouldn't have to write any custom
ifs and be able to output the joinphrase value as-is, whitespace and everything.