Skip to content

Instantly share code, notes, and snippets.

@bulkan
Created March 6, 2018 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bulkan/d714212aa3c6dc21e717f51c07482f83 to your computer and use it in GitHub Desktop.
Save bulkan/d714212aa3c6dc21e717f51c07482f83 to your computer and use it in GitHub Desktop.
example of munging JSON using jq and still getting valid JSON
#!/bin/bash
cat item.json | jq 'map( {
amount: .amount,
yieldFactor: .yieldFactor,
servingSize: .servingSize | { gramsEntered: .gramsEntered },
measures: .measures | map( {
amount: .amount,
gramsPerUnit: .gramsPerUnit
}),
foodComponents: .foodComponents
})'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment