Why not eval() JSON?

前端 未结 6 802
再見小時候
再見小時候 2020-12-10 06:14

As far as I know it is considered bad practice to eval() JSON objects in JavaScript, because of security. I can understand this concern if the JSON comes from a

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 06:56

    Besides the obvious security issues:

    1. Native JSON is faster
    2. You don't need to "load" a JSON parser it's just another function call to the JavaScript engine

提交回复
热议问题