Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

Filomena Giffard




Posted Questions



Wait...

Posted Answers



Answer


For all of the below, it's assumed that your content is in a shell variable named s:

This requires very new (probably 1.5?) jq to work, and is a dense chunk of code. To break it down:

This will work with a significantly older jq than the above, and is an easily adopted approach for scenarios where a native-jq solution can be harder to wrangle:

The invoked jq command from the above is similar to:

...passing each key and value out-of-band (such that it's treated as a literal string rather than parsed as JSON), then referring to them individually.

Either of the above will emit:

In short: Because it's guaranteed to generate valid JSON as output.

Consider the following as an example that would break more naive approaches:

Sure, these are unexpected scenarios, but jq knows how to deal with them:


Answer is posted for the following question.

How to use jq to create json?

Answer


This article explores some of the fundamental concepts that govern the health insurance industry, as well as some of the most common sources of health coverage


Answer is posted for the following question.

How to read a health insurance plan?


Wait...