Can I store RegExp and Function in JSON?
Given a block like this: var foo = {"regexp":/^http:\/\//, "fun":function(){}, } What is a proper way to store it in JSON? You have to store the RegExp as a string in the JSON object. You can then construct a RegExp object from the string: // JSON Object (can be an imported file, of course) // Store RegExp pattern as a string // Double backslashes are required to put literal \ characters in the string var jsonObject = { "regex": "^http:\\/\\/" }; function fun(url) { var regexp = new RegExp(jsonObject.regex, 'i'); var match; // You can do either: match = url.match(regexp); // Or (useful for