How to restore original object/type from JSON?

前端 未结 6 1687
旧时难觅i
旧时难觅i 2020-12-05 19:38

Its easy to load JSON into an object in javascript using eval or JSON.parse.

But if you have a proper \"class\" like function, how do you get the JSON data into it?<

6条回答
  •  眼角桃花
    2020-12-05 19:55

    Easiest way is to use JSON.parse to parse your string then pass the object to the function. JSON.parse is part of the json2 library online.

提交回复
热议问题