How to write routine to escape double quotes in a JSON stringHow do I escape quotes for json conversion in...
Arriving at the same result with the opposite hypotheses
Soft question: Examples where lack of mathematical rigour cause security breaches?
How to use memset in c++?
Does Disney no longer produce hand-drawn cartoon films?
CROSS APPLY produces outer join
Geopandas and QGIS Calulating Different Polygon Area Values?
Pre-1972 sci-fi short story or novel: alien(?) tunnel where people try new moves and get destroyed if they're not the correct ones
Thread Pool C++ Implementation
Winning Strategy for the Magician and his Apprentice
How can I make some of my chapters "come to life"?
Is this use of the expression "long past" correct?
Someone whose aspirations exceed abilities or means
Does a scale have more than seven chords?
Were Alexander the Great and Hephaestion lovers?
Overlapping String-Blocks
Is using haveibeenpwned to validate password strength rational?
A IP can traceroute to it, but can not ping
How to safely destroy (a large quantity of) valid checks?
What is the maximum number of net attacks that one can make in a round?
What setting controls moving the cursor on the command line?
Is separation provided in class F airspace?
Meaning of 'lose their grip on the groins of their followers'
Is it possible to have a wealthy country without a middle class?
How does an ordinary object become radioactive?
How to write routine to escape double quotes in a JSON string
How do I escape quotes for json conversion in BashUsing sed to replace a string with special chars with another string with special charactersHow to pass string with special characters to shell command in a script?grab text out of vtt fileIs it possible to not escape double quotes and get the right json format?Escaping single quotes **with** an aliasHow to pass a value that has to be in quotes to a command?How to replace this regex with a empty using sedRunning script through ssh and evaluate some var/comand inside the host machineFind and replace inside string based on pattern and exception cases
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have to be efficient so I can't use tools like jq
which loads up a big binary executable. I just want to escape double quotes in a string so it's safe for JSON. This isn't good enough:
echo ' bad " string"' | sed 's/"/\"/g'
because it will escape double quotes that are already escaped. Is there a way to replace double quotes only if they are not already escaped?
bash shell json
add a comment |
I have to be efficient so I can't use tools like jq
which loads up a big binary executable. I just want to escape double quotes in a string so it's safe for JSON. This isn't good enough:
echo ' bad " string"' | sed 's/"/\"/g'
because it will escape double quotes that are already escaped. Is there a way to replace double quotes only if they are not already escaped?
bash shell json
add a comment |
I have to be efficient so I can't use tools like jq
which loads up a big binary executable. I just want to escape double quotes in a string so it's safe for JSON. This isn't good enough:
echo ' bad " string"' | sed 's/"/\"/g'
because it will escape double quotes that are already escaped. Is there a way to replace double quotes only if they are not already escaped?
bash shell json
I have to be efficient so I can't use tools like jq
which loads up a big binary executable. I just want to escape double quotes in a string so it's safe for JSON. This isn't good enough:
echo ' bad " string"' | sed 's/"/\"/g'
because it will escape double quotes that are already escaped. Is there a way to replace double quotes only if they are not already escaped?
bash shell json
bash shell json
asked 2 mins ago
Alexander MillsAlexander Mills
2,46921963
2,46921963
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523203%2fhow-to-write-routine-to-escape-double-quotes-in-a-json-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523203%2fhow-to-write-routine-to-escape-double-quotes-in-a-json-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown