dima85,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
</head>
<body>
<textarea id="foo" rows="25">
{
"id":"test1",
"select":"dsfsdf",
"text":"dsfdsf"
},
{
"id":"test2",
"number":"22",
"text":"dsfdsf"
},
{
"id":"test3",
"select":{"ok":"no"},
"text":"dsfdsf"
}
</textarea>
<script>
document.getElementById("foo").onmouseup = function() {
var a = this.value,
d = this.selectionStart,
b = a.indexOf("{"),
c = a.lastIndexOf("}");
if (!(d < b || d > c)) {
for (var a = this.value, e = JSON.parse("[" + a + "]"), b = /\}\s*?,\s*?\{/g, c = 0; null != b.exec(a) && b.lastIndex < d;) c++;
alert(e[c].id)
}
};
</script>
</body>
</html>