Mardoxx Posted July 29, 2009 Share Posted July 29, 2009 I am using JSON but I get my Object data as a string. Is there any way to convert the stringed object text to an Object? var Object = {"bindings": [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}, {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"}, {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"} ] }; That code creates an object called myJSONObject, correct? (yes) BUT how can I do this? Convert the String to an object var String = '{"bindings": [ {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}, {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"}, {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"} ] }'; var Object = eval(String); does not work... any ideas? OH MY GOD I'M SUCH A RETARD check this: I had the code x = tmp.load( JSON.stringify(data_1) ); so all I needed to do was x = tmp.load(data_1); PROTIP: GET SOME SLEEP but as a general case I found this: var object = eval( '(' + string + ')'); Link to comment https://forums.phpfreaks.com/topic/167906-solved-a-little-which-turns-out-to-be-a-big-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.