Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

store Latex in Json format

I am building a math exercises database, I would like to use couchDB and then store the exercises in a json format, so I can store meta-data with each exercise.

I have troubles having a valid json with all the Latex syntax, what would be a good way to tackle this issue? I have thought about encoding the latex but I am not sure it's a good idea, above all if it will need to be decoded by a mobile device...

Example of data:

     {"taglist": null,
     "flagcount": null,
     "category": "Algebre",
     "chapter": "Polynomes",
     "difficulty": 1,
     "viewcount": null,
     "hint": null,
     "question": "Soit $P \in \mathbb{R}[X]$ scindé sur $\mathbb{R}$.\\ \begin{enumerate} \item Montrer que $P'$ est aussi scindé sur $\mathbb{R}$. \item Montrer que les racines multiples de $P'$ sont aussi racines de $P$. \item Ce resultat reste-t-il valable dans $\mathbb{C}[X]$ ? \end{enumerate}"
     "solution": null}

Moreover, as I might need to encrypt the "solution" because I do no want it to be accessed without permission, maybe I should store only the encrypted form in the json?

Or maybe the solution is to store the latex another way... ? I am very new to this kind of problem, I appreciate any help ;).

Thanks

like image 679
edelans Avatar asked Oct 21 '25 11:10

edelans


1 Answers

In JSON strings backslash character \ have special meaning. If you want to store it in your data use \\ (escaped backslash). JSON parser will change it back to the single one and Couch should store "$\\mathbb{R}$.\\\\" as $\mathbb{R}$.\\.

like image 86
Marcin Skórzewski Avatar answered Oct 23 '25 00:10

Marcin Skórzewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!