Use Greek with JSON

This is JSON, I write and use it with jQuery.

bookData.webSites = [ { id: 1, title: "ΤΟΥΡΙΣΤΙΚΗ ΑΝΑΠΤΥΞΗ", image: 'images/books/min.png', site: 'http://delicious.com/', author: "", pages: '', isbn: '', price: '', type: 'book' }]; 

It works fine until I try to use a long Greek text with it, then it really is not. I had some problems with the author tag, but everything went well when I used "" instead of '' . In the long Greek text, we use " and ' during recording, and I apparently want to use the Greek for the description. Any way for this has become possible.

Thanks in advance for the help of each of this AWESOME community!

+4
source share
1 answer

Try putting an escape character ( '\' ) before each instance of " or ' .

JSON JavaScript libraries should handle this for you. An example is http://www.json.org/js.html : see JSON.stringify .

+3
source

Source: https://habr.com/ru/post/1302424/


All Articles