Skip to content

use Jsonitor instead of encoding/json #285

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

Merged
merged 2 commits into from
Jan 4, 2018
Merged

Conversation

wonderflow
Copy link
Contributor

@wonderflow wonderflow commented Jan 3, 2018

Fixes [issue number]

Changes

主要集中在2个优势

  1. 纯粹的unmashal函数,性能优于标准库
  2. 可以预置jsonnumber的config,然后用纯粹的unmashal,标准库只能用decoder的形式,会有buffer的gc开销

Reviewers

Wiki Changes

  • options1...
  • options2...

Checklist

  • Rebased/mergable
  • Tests pass
  • Wiki updated

@@ -37,6 +37,11 @@ const (

const MaxParserSchemaErrOutput = 5

var jsontool = jsoniter.Config{
EscapeHTML: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个字段是指忽略 html ? 会不会影响用户的数据?

}

func NewJsonParser(c conf.MapConf) (LogParser, error) {
name, _ := c.GetStringOr(KeyParserName, "")
labelList, _ := c.GetStringListOr(KeyLabels, []string{})
nameMap := map[string]struct{}{}
labels := GetLabels(labelList, nameMap)
jsontool := jsoniter.Config{
EscapeHTML: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EscapeHTML是json标准库默认的行为

@wonderflow
Copy link
Contributor Author

发现了一个jsoniter不适配的地方:json-iterator/go#217

@andrewei1316
Copy link
Collaborator

LGTM

@wonderflow wonderflow merged commit e0b4f5c into qiniu:develop Jan 4, 2018
@wonderflow wonderflow deleted the jsonitor branch January 4, 2018 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants