Skip to content

Instantly share code, notes, and snippets.

@SuperPaintman
Created September 3, 2016 04:57
Show Gist options
  • Save SuperPaintman/27f9f769fe980ac14f495684c8fbd310 to your computer and use it in GitHub Desktop.
Save SuperPaintman/27f9f769fe980ac14f495684c8fbd310 to your computer and use it in GitHub Desktop.
escape_json () {
echo "${1//$'\n'/\\n}" | sed 's/\\/\\\\/g' | sed 's/\\\\n/\\n/g' | sed 's/"/\\"/g' | sed "s/'/\\'/g"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment