In order to be parsed as an object, the data attribute must be a well formed JSON object.
In your case you just need to quote the object keys (as you do in the second object). Try:
<div data-params="{"a": 1, "b": "2"}" id="TEST1"></div>
For more info see the data method docs, the relevant part is this one (emphasis mine):
Every attempt is made to convert the string to a JavaScript value
(this includes booleans, numbers, objects, arrays, and null) otherwise
it is left as a string… …When the
data attribute is an object (starts with'{') or array (starts with
'[') thenjQuery.parseJSONis used to parse the string; it must follow
valid JSON syntax including quoted property names.