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 + ')'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.