Convert string to be a valid to use in json

I have a little question for my json string. I have something like this:

        "index": 0,
        "name": "block

But its needs to be a valid json string with the new lines and these quotes. Is there somthing i can do in javascript to replace the string to make this json string

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.