-
-
Notifications
You must be signed in to change notification settings - Fork 208
Regex stringify proposal #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
type: 'RegExp' is not part ot jsonschema. How about adding this behavior to type: 'string'? |
|
Yeah, you are right. For example: // $asString function
str = /"([^"]|\\")*"/
if (str instanceof RegExp) {
$asRegExp(str)
}
// $asString codeIf the user passes The only solution I see here, is to escape |
|
This is json-schema, it's a spec :/. So, +1 for making it a part of $asString. Open a separate issue for escaping, because I fear that might have bugs in general (for / as an example). |
|
or \ maybe :). |
|
Sorry, made a little mess with commit messages :P Is better now? |
|
That's ok. I'll merge when I get back. You can do a git rebase to squash all commits into one.. :) |
0745be6 to
f78eb97
Compare
|
Done, thanks! |
|
Can you please add some notes in the README about this? |
|
Sure, which one you prefer?
or
In my opinion the second is better, is more clean. |
|
Agreed, do the 2nd.
|
JSON by default does not support RegExp objects or strings, I propose to add
RegExptype to the schema types.In this way fast-json-stringify will transform regex object in escaped strings and not in
'{}'as JSON.stringify does.Example:
What do you think?