TextArea containing JSO
HTML
<textarea id='myTextarea' wrap='off' style='width:95%; height:240px font-family:"Lucida Console" font-size:11px;'> [ {
title: 'RadioButtons Choice',
sectionName: 'Normal Section',
type: 'CI.iSheet.ReproduceSheet.properties.choiceField',
choices: [{choice:' choice 1'},{choice:' choice 2'},{choice:' choice 3'}],
userSelection: false,
choiceType: 'CI.iSheet.ReproduceSheet.properties.choiceType.radioButtons',
mandatory: false
},
];</textarea>
<button id='pressme'>
Press me
</button>
<div id="result">
</div>
JavaScript
$("#pressme").on("click",function(ev) {
var objStr = $("#myTextarea").val();
console.log(objStr);
var obj =eval(objStr);
console.log(obj);
$("#result").html(obj[0].mandatory);
var obj2 = JSON.parse(objStr);
console.log(obj2)
});