First of all, apply htmlentities() in your json_encode() call to ensure that all quotes are okay in HTML.
jQuery already does JSON parsing on data- attributes for you, if it contains valid JSON syntax. So doing the following is the right way of doing it:
// this will contain the JSON presentation of $row variable from PHP.
var res = $(this).data("myvar");
From the jQuery Docs:
Every attempt is made to convert the string to a JavaScript value
(this includes booleans, numbers, objects, arrays, and null). A value
is only converted to a number if doing so doesn't change the value's
representation. For example, "1E02" and "100.000" are equivalent as
numbers (numeric value 100) but converting them would alter their
representation so they are left as strings. The string value "100" is
converted to the number 100.
When the data attribute is an object (starts with '{') or array
(starts with '[') then jQuery.parseJSON is used to parse the string;
it must follow valid JSON syntax including quoted property names. If
the value isn't parseable as a JavaScript value, it is left as a
string.
Working fiddle
$(this).data("myvar")and see what that returns :)