<div class="block js-block-obj" data-info="{ b 10, s: 1 }"></div>
console.log( $('.js-block-obj').data('info') );
$( ".js-block-obj" ).data( "info", { b: 100, s: 0 } );
console.log( $('.js-block-obj').data('info') );
<div class="block js-block-obj" data-info="{ b: 10, s: 1 }"></div>
...
$.fn.jsonData = function(name) {
var data = this.data(name);
if (typeof data === "string") {
data = JSON.parse(data);
this.data(name, data);
}
return data;
};
...
console.log( $('.js-block-obj').jsonData('info') );
$( ".js-block-obj" ).data( "info", { b: 100, s: 0 } );
console.log( $('.js-block-obj').jsonData('info') );