<div id ="test" data-something='{"something":"something"}'></div>
string in the data-attribute is automatically converted to a JavaScript object.
you can access this in javascript like this.
var somethingObject = $("#test").data("something");
var jsonSomethingObject = JSON.stringify(somethingObject);
console.log(somethingObject); //this will print the main javascript object
console.log(jsonSomethingObject);// this will print stringify javascript object
you can refer the snippet for same
var someObject = $("#test").data("student");
var jsonData = JSON.stringify(someObject);
$('#display').text("id:"+someObject.id +" name:"+someObject.name)
console.log(someObject);
console.log(jsonData);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="test" data-student='{"name": "Dhiraj", "id": 1}' />
<div id="display"></div>