gin icon indicating copy to clipboard operation
gin copied to clipboard

[Feature]: Support custom json codec at runtime

Open timandy opened this issue 3 years ago • 26 comments
trafficstars

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

timandy avatar Nov 10 '22 01:11 timandy

@appleboy Please take a look, thanks~

timandy avatar Nov 10 '22 01:11 timandy

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.

codecov[bot] avatar Apr 26 '23 09:04 codecov[bot]

good job! I need the feature.

aohanhongzhi avatar Jul 15 '23 12:07 aohanhongzhi

@timandy We move to the next milestone v1.11

appleboy avatar Apr 01 '24 04:04 appleboy

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

fifsky avatar Apr 01 '24 06:04 fifsky

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.

devhaozi avatar May 07 '24 10:05 devhaozi

@timandy Can you create a new PR? I can't handle this PR (maybe no permission to trigger CI testing)

appleboy avatar May 07 '24 10:05 appleboy

@appleboy All right, I will rebase on the latest commit.

timandy avatar May 08 '24 01:05 timandy

@timandy Thanks.

appleboy avatar May 08 '24 01:05 appleboy

@aohanhongzhi I have rebased it, Please tabke a look.

timandy avatar May 08 '24 01:05 timandy

related: https://github.com/gin-gonic/gin/issues/3766

appleboy avatar May 09 '24 03:05 appleboy