-4

I have a simple problem with my json file.

That json file can describe like this:

{
    "motto": "<span class="text-success">IF</span> YOU FAIL, TRY AGAIN"
}

How to put " inside motto property ? Thanks for advice

Jordy
  • 1,802
  • 2
  • 6
  • 25
  • 3
    To the answerers: Don't answer questions that are duplicates, especially ones that are obvious duplicates. Instead, vote to close the question as a duplicate. – Ouroborus Nov 21 '22 at 10:54

3 Answers3

1

You can escape the inner double quotes around the class by using a \ like so;

{
    "motto": "<span class=\"text-success\">IF</span> YOU FAIL, TRY AGAIN"
}

This will make it so the quotes immediately after the \ are seen as part of the string.

Mike Donkers
  • 3,589
  • 2
  • 21
  • 34
1

You just have to escape them:

{
    "motto": "<span class=\"text-success\">IF</span> YOU FAIL, TRY AGAIN"
}

just one backslash ( \ ) in front of quotes.

Abdulrahman Hashem
  • 1,481
  • 1
  • 15
  • 20
1

It's as easy as pie. Just escape your inner quotation marks with a backslash. So, your example will look like:

{
    "motto": "<span class=\"text-success\">IF</span> YOU FAIL, TRY AGAIN"
}
andrewsha
  • 177
  • 3