gin/PR_DESCRIPTION.md
2026-01-24 00:45:32 -08:00

1.7 KiB

What problem does this PR solve?

Issue Number: Close #2810

Problem Summary: Users have requested an example of how to integrate json-iterator with Gin at runtime (without using build tags). While there is documentation, a runnable example project is helpful for understanding the integration points, specifically implementing the json.Core interface and replacing json.API.

What is changed and how does it work?

  • Added a new example under examples/json-iterator.
  • Implemented customJsonApi which wraps jsoniter.Config and implements json.Core.
  • Demonstrates how to replace the default json.API with the custom implementation.
  • Added a unit test to verify the integration works as expected.
  • Added a README for the example explaining how to run and test it.

Check List

Tests

  • Unit test
    • Added examples/json-iterator/json_iterator_test.go
  • Integration test
  • Manual test
    • Verified with curl locally.
  • No code

Code changes

  • Has the configuration change
  • Has HTTP API interfaces changed
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

How to Test

  1. Navigate to the example directory:
    cd examples/json-iterator
    
  2. Run the tests:
    go test -v
    
  3. Run the example:
    go run main.go
    
  4. Make a request:
    curl http://localhost:8080/ping