Is it valid to define functions in JSON results?

后端 未结 11 875
一向
一向 2020-11-22 11:38

Part of a website\'s JSON response had this (... added for context):

{..., now:function(){return(new Date).getTime()}, ...}

Is adding anony

11条回答
  •  孤城傲影
    2020-11-22 12:12

    although eval is not recommended, this works:

    
    
    
    
    

    Convert a string written in JSON format, into a JavaScript function.

提交回复
热议问题