gin
gin copied to clipboard
[Feature]: Support custom json codec at runtime
Extract out an interface json.Core to define all serialization and deserialization behaviors.
Developers only need to implement the interface and set the value of json.API to custom json codec.
In the future, we can define xml.Core in the same way.
Solved #3217
@appleboy Please take a look, thanks~
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.19%. Comparing base (
3dc1cd6) to head (2118c7c). Report is 63 commits behind head on master.
:exclamation: Current head 2118c7c differs from pull request most recent head eeaa150
Please upload reports for the commit eeaa150 to get more accurate results.
Additional details and impacted files
@@ Coverage Diff @@
## master #3391 +/- ##
==========================================
- Coverage 99.21% 99.19% -0.03%
==========================================
Files 42 43 +1
Lines 3182 2722 -460
==========================================
- Hits 3157 2700 -457
+ Misses 17 12 -5
- Partials 8 10 +2
| Flag | Coverage Δ | |
|---|---|---|
? |
||
| -tags "sonic avx" | 99.18% <100.00%> (?) |
|
| -tags go_json | 99.18% <100.00%> (?) |
|
| -tags nomsgpack | 99.17% <100.00%> (?) |
|
| go-1.18 | ? |
|
| go-1.19 | ? |
|
| go-1.20 | ? |
|
| go-1.21 | 99.19% <100.00%> (-0.03%) |
:arrow_down: |
| go-1.22 | 99.19% <100.00%> (?) |
|
| macos-latest | 99.19% <100.00%> (-0.03%) |
:arrow_down: |
| ubuntu-latest | 99.19% <100.00%> (-0.03%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
good job! I need the feature.
@timandy We move to the next milestone v1.11
I recommend removing all third-party JSON packages after defining the JsonApi to reduce dependencies. Related discussion: https://github.com/gin-gonic/gin/issues/3653#issuecomment-1614022681
We should not piling json libraries
I recommend removing all third-party JSON packages after defining the JsonApi to reduce dependencies. Related discussion: #3653 (comment)
We should not piling json libraries
Agree with this, I don't want to see four different json implementations in one web framework.
@timandy Can you create a new PR? I can't handle this PR (maybe no permission to trigger CI testing)
@appleboy All right, I will rebase on the latest commit.
@timandy Thanks.
@aohanhongzhi I have rebased it, Please tabke a look.
related: https://github.com/gin-gonic/gin/issues/3766