Best way to convert JSON data to an object in JavaScript?

前端 未结 1 1733
情深已故
情深已故 2021-01-26 06:57

I am currently using eval in JavaScript to convert JSON data returned from the server into an object.

eval (\"myObject=\"+data);

I

相关标签:
1条回答
  • 2021-01-26 07:24

    The reason eval is considered a bad practice is that user can evaluate anything that is sent from the server. This means if you have comments forum and the user submits some JavaScript code for the comments and you eval on the client side then your website can easily be hijacked.

    I like the JQuery-Json plug-in. You can check it out using the following link:

    link text

    0 讨论(0)
提交回复
热议问题