Reputation: 437
I have an input on a form which stores values as an object.
jQuery('#inputId').val()
returns something like
'[{"Id":"123","Name":"A","PathOfTerm":"A","Children":[],"Level":0,"RawTerm":null},{"Id":"234","Name":"B","PathOfTerm":"B","Children":[],"Level":0,"RawTerm":null}]'
as one single string. Is there any way to either prevent this from automatically converting to a string (maybe not using .val?) or to convert this from a string to something I could work with?
Upvotes: 0
Views: 118
Reputation: 510
Here you go
var array = JSON.parse(jQuery('#inputId').val());
Upvotes: 5