1

I need to store some math formulas inside a database that is to be retrieved in json.

I'm trying http://jsonviewer.stack.hu/ to test in file and can't correctly display the following:

{'ej':'\frac{25x^3+2y}{12x}'}

reason is that it getds rid of "\f", so instead of \frac rac is displayed.

How can I fix this?

pxs
  • 77
  • 6

1 Answers1

1

As @R Pasha mentioned, you need to escape the backslash \ in the JSON with another backslash \

Example string would be: {"ej":"\\frac{25x^3+2y}{12x}"}

Note: also that you should be using double-quotes for your JSON.

Justin F
  • 251
  • 5
  • 13
  • Single quotes are considered invalid, so you may run into issues parsing the string later. See: https://stackoverflow.com/questions/14355655/jquery-parsejson-single-quote-vs-double-quote – Justin F Jul 01 '20 at 19:58