-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
add json ASCII string render #1358
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1358 +/- ##
==========================================
+ Coverage 97.99% 98.01% +0.02%
==========================================
Files 36 36
Lines 1841 1860 +19
==========================================
+ Hits 1804 1823 +19
Misses 30 30
Partials 7 7
Continue to review full report at Codecov.
|
context_test.go
Outdated
w := httptest.NewRecorder() | ||
c, _ := CreateTestContext(w) | ||
|
||
c.AsciiJSON(204, []string{"lang", "Go语言"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change 204
to http
status code in HTTP package for maintainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which status code should i use? you mean http.StatusNoContent
or using other status code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http.StatusNoContent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@thinkerou Please help to review this PR. |
type SecureJSONPrefix string | ||
|
||
var jsonContentType = []string{"application/json; charset=utf-8"} | ||
var jsonpContentType = []string{"application/javascript; charset=utf-8"} | ||
var jsonAsciiContentType = []string{"application/json"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add charset-utf-8
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, needn't. it's ascii.
render/json.go
Outdated
} else { | ||
cvt = fmt.Sprintf("\\u%04x", int64(r)) | ||
} | ||
result = result + cvt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@duguying If you can add some example codes and comments to README, it's very nice, thanks! |
@thinkerou readme added. |
README.md
Outdated
"tag": "<br>", | ||
} | ||
|
||
// will output : {"lang":"GO\u8bed\u8a00","tag":"\u003cbr\u003e"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
LGTM, thanks! |
add a json render that rendering json as ASCII string