JSON JS escaping#1736
Merged
Merged
Conversation
289df35 to
a7da11d
Compare
Until now, we've had a hardcoded set of characters that would always be escaped in JSON; these were never modifiable. We now plug in to the new RenderSettings case class to add the ability to specify sets of characters that should be escaped. Additionally, we add a default set of such characters that corresponds to the characters that must be escaped when JSON is evaluated directly by a JavaScript engine rather than by a valid JSON parser (as when using JSON-P). Lastly, we provide two default RenderSettings instances, prettyJs and compactJs, that encapsulate the appropriate escaping with pretty or compact rendering.
a7da11d to
c4bd2f8
Compare
Member
There was a problem hiding this comment.
Maybe this should mention it's only for JSON instead of expecting people to click through to the render settings docs? Also, could we make the reference to those settings a link?
Member
Author
There was a problem hiding this comment.
Not sure what you mean regarding “only for JSON”—it's in JsonAST and lift-json, right?
I'll definitely make them a link, good catch.
Member
|
I like it. |
Member
Author
|
We probably also need to change Lift's built-in stuff to use the right render settings :/ |
Member
Author
|
Actually just kidding, this is only for stuff that parses JSON as JS, and the Lift JSON stuff generally is parsed as JSON on the browser, so we're good. |
Member
Author
|
@farmdawgnation dropped some links on the scaladocs 🎉 |
Member
|
👍 |
farmdawgnation
added a commit
that referenced
this pull request
Dec 2, 2015
Until now, we've had a hardcoded set of characters that would always be escaped in JSON; these were never modifiable. We now plug in to the new RenderSettings case class to add the ability to specify sets of characters that should be escaped. Additionally, we add a default set of such characters that corresponds to the characters that must be escaped when JSON is evaluated directly by a JavaScript engine rather than by a valid JSON parser (as when using JSON-P). Lastly, we provide two default RenderSettings instances, prettyJs and compactJs, that encapsulate the appropriate escaping with pretty or compact rendering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a few scaladocs beyond the core work. The main commit:
Until now, we've had a hardcoded set of characters that would always be escaped
in JSON; these were never modifiable. We now plug in to the new
RenderSettingscase class to add the ability to specify sets of characters that should be
escaped.
Additionally, we add a default set of such characters that corresponds to the
characters that must be escaped when JSON is evaluated directly by a JavaScript
engine rather than by a valid JSON parser (as when using JSON-P).
Lastly, we provide two default
RenderSettingsinstances,prettyJsandcompactJs, that encapsulate the appropriate escaping with pretty or compactrendering.
Closes #1676.