Reputation: 3097
How can I convert a multiline variable with special characters into a JSON string using JQ?
$ echo $FPR_LOW
4 issues of 4 matched search query.
Issue counts by category:
J2EE Bad Practices: Leftover Debug Code => 1 Issues
ApiApplication.java:23 (Structural)
Poor Error Handling: Overly Broad Throws => 3 Issues
controller/BanksController.java:27 (Structural)
controller/BanksController.java:40 (Structural)
controller/BanksController.java:51 (Structural)
The above string variable should be a single JSON string.
Upvotes: 0
Views: 112
Reputation: 52334
Pass the value as a jq
variable (and tell it not to expect input):
jq -n --arg fpr "$FPR_LOW" '$fpr'
Upvotes: 2