I have an html page with a single-line javascript comment as follows:
// {"key1":"value1"}, {"key2":"value2"}, {"key3":"value3"}
<b> Sample Text </b>
I want to retrieve all the key value pairs in the comment and place them in javascript maps. How would I parse it using js/jquery? I am terrible at regexes so any help would be appreciated. If it helps, The comment will always be only the first line in the html.
EDIT:
If it makes the job easier, I could also work with –
/* {"key1":"value1"}, {"key2":"value2"}, {"key3":"value3"} */
<b> Sample Text </b>
Instead of writing the javascript to the top of the HTML, write it inside a script element like so:
You should have access to x with your data like any other javascript object.