>
> On Jan 18, 2013, at 1:19 PM, Stephen Bartell <[email protected]> wrote:
>
>> The problem is stringifying the snippets into json. What I currently do is
>> just compress my js, then paste it into the document via futon's create new
>> document page. This seems to work fine. Unless regex is involved, obviously
>> because regex isn't a JSON primitive.
>
> I don’t think this has anything to do with regexes. It shouldn’t matter
> what’s in your JS code (or even whether it’s JS or Erlang or FORTRAN) as long
> as you’ve properly quoted it. To the document it’ll just be a string.
>
> How are you quoting the code?
I use double quotes for the string as a whole, and then single quotes for
quotes in the string.
Example:
{
"map": "function (a, b) {var res = b.match(/(\d+)/); console.log('this is the
res:' + res)}"
}
This shows I use regex escapes, and it shows how I do quotes (in the
console.log fund).
This won't store properly via futon. Meaning, if I put this into a document
via futon, the value will become a string, not a json object.
I think it might come down to the regex escape "\d+". If i use "d+" instead,
then futon will accept the object. But then running the snippet won't work
because i intend to have "\d+".
>
> —Jens