https://github.com/mehditeymorian/json
standard 'encoding/json' module with 'in' and 'out' options to have more control over decoding and encoding
https://github.com/mehditeymorian/json
encoder-decoder golang golang-module json
Last synced: about 1 month ago
JSON representation
standard 'encoding/json' module with 'in' and 'out' options to have more control over decoding and encoding
- Host: GitHub
- URL: https://github.com/mehditeymorian/json
- Owner: mehditeymorian
- Created: 2023-01-20T12:16:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-20T12:51:56.000Z (over 2 years ago)
- Last Synced: 2025-01-23T17:34:34.362Z (3 months ago)
- Topics: encoder-decoder, golang, golang-module, json
- Language: Go
- Homepage:
- Size: 197 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Encoding Json
Golang standard `encoding/json` module with more options to have more control over encoding and decoding.## Options
- `in`: used to include a field only in decoding
- `out`: used to include a field only in encoding## Description
| example | description |
|--------------------|-------------------------------------------|
| json:"-" | field is ignored |
| json:"name" | field is included in `input` and `output` |
| json:"name,in" | field is only included in `input` |
| json:"name,out" | field is only included in `output` |
| json:"name,in,out" | field is included in `input` and `output` |## Example
Considering the following struct as an example:
- included in decode(unmarshalling):
- name
- password
- included in encode(marshalling):
- name
- balance```go
package maintype User struct {
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password,in"`
Balance uint `json:"balance,out"`
}
```# Acknowledgment
This module is a copy of `encoding/json` module from Go version `1.19`.