my_str
seems to be already an object. So you just don't need to use `JSON.parse.
Because, probably, my_str.toString()
is equal to
[object Object]
^---------------- Unexpected token o
If you use jQuery.ajax
remember that jQuery
convert automatically JSON input data if it match coherent header
Content-type: application/jso
and/or if you set the .ajax
option
dataType:'json'
if you're declaring manually my_str =
then simply you should add quotes around the string (and put it into a single line or use some tip in order to do multiline string)
var my_str = '{"key1":"val1","key2":"","keyObj":{"key3":300,"key4":259200}}';
but doing manually has not much sense.